microsoft / ProjectAcoustics

Microsoft Project Acoustics
https://aka.ms/acoustics
Creative Commons Attribution 4.0 International
141 stars 22 forks source link

pythonnet can't load DLL (LoadFromRemoteSources) #155

Open simdax opened 1 year ago

simdax commented 1 year ago

Hello.

I have some problems when opening a project with the plugin

LogPython: Error: System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.
LogPython: Error: The above exception was the direct cause of the following exception:
LogPython: Error: Traceback (most recent call last):
LogPython: Error:   File "E:/dev2/Game/NXT/Plugins/ProjectAcousticsWwise/Content/Python/init_unreal.py", line 3, in <module>
LogPython: Error:     import init_project_acoustics
LogPython: Error:   File "E:\dev2/Game/NXT/Plugins/ProjectAcousticsWwise/Content/Python\init_project_acoustics.py", line 52, in <module>
LogPython: Error:     clr.AddReference("Microsoft.Azure.Batch")
LogPython: Error: System.IO.FileLoadException: Could not load file or assembly 'file:///E:\dev2\Game\NXT\Plugins\ProjectAcousticsWwise\Source\ThirdParty\Win64\Release\Microsoft.Azure.Batch.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)
LogPython: Error: File name: 'file:///E:\dev2\Game\NXT\Plugins\ProjectAcousticsWwise\Source\ThirdParty\Win64\Release\Microsoft.Azure.Batch.dll' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for
 more information.
LogPython: Error:    at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
LogPython: Error:    at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
LogPython: Error:    at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
LogPython: Error:    at System.Reflection.Assembly.LoadFrom(String assemblyFile)
LogPython: Error:    at Python.Runtime.AssemblyManager.LoadAssemblyPath(String name)
LogPython: Error:    at Python.Runtime.CLRModule.AddReference(String name)

I have to admit I also had to copy myself a version of pycparser directly in the lib folder because it was not found by unreal (albeit I could import it directly from the UE/Engine/Binaries python ....).

I'm not sure of the root of this, if someone has any idea ??

NoelCross commented 1 year ago

@simdax Thanks for your question and interest in the project. It does seems strange that you needed to manually copy pycparser since that is usually included in your UE engine install. Perhaps there was an issue during the install.

Also, check that you don't have the Mark of the Web on the Project Acoustics binaries that you downloaded and unzipped. If you select the files in the Project Acoustics plugin folder and check the file properties to see if there are any files that are marked as blocked. If any are marked as blocked, feel free to unblock those files.

image

simdax commented 1 year ago

Hello Noel, thank you for your answer.

Strangely I don't have this icon on my pc ! exactly the same as yours, without the security panel :)

NoelCross commented 1 year ago

@simdax it appears that you don't have an issue with Mark of the Web. I'm still not sure what's going on, but there is a series of workarounds that are covered in this issues thread that could possibly unblock you.

Workarounds

Could you try each of the workarounds to see if it gets you any further?

noubar commented 4 months ago

https://stackoverflow.com/questions/28339116/not-allowed-to-load-assembly-from-network-location

This solution has worked for me