4
$\begingroup$

Note: Answering my own question as a wiki for future reference.

When loading a .Net DLL:

<< NetLink`
InstallNET[]
LoadNETAssembly["C:\\Temp\\XYZ.dll"]
NETAssembly["XYZ", 1]

I get the error:

NET::netexcptn: A .NET exception occurred: System.IO.FileLoadException: Could not load file or assembly file:///C:\Temp\XYZ.dll'or one of its dependencies. Operation is not supported.(ExceptionfromHRESULT:0x80131515)

Filename:'file:///C:\Temp\XYZ.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....

$\endgroup$
6
$\begingroup$

The DLL file was Blocked.

The solution was to Unblock it (right click on DLL > choose Properties > click the Unblock button).

You need to restart Mathematica and load the DLL in again.

enter image description here

| improve this answer | |
$\endgroup$
3
$\begingroup$

As per MSDN:

Note You may get a FileLoadException in a Windows Virtual PC application when you try to load a file from linked folders on the hosting computer. This error may also occur when you try to load a file from a folder linked over Remote Desktop Services (Terminal Services). To avoid the exception, set enabled to true.

I was able to resolve this problem using the <loadFromRemoteSources> Element and adding the settings to my config.

<configuration>
   <runtime>
      <loadFromRemoteSources enabled="true"/>
   </runtime>
</configuration>
| improve this answer | |
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.