.Net 4.0 : Getting error
an attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed
applied setting
<loadFromRemoteSources enabled="true"/>
didn't help. How can i get to know which assembly is causing problem? How can i resolve it?
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.
In summary if you get the "Could not load file or assembly error", this means that either your projects or their references were built with a reference to a specific version of an assembly which is missing from your bin directory or GAC.
I have also ran into this issue, but my problem occurred because the file had been blocked since it was downloaded from an unsecured source, GMail in my case. I solved it by
In my case it was the entire .zip file that was unsafe, so I unblocked the file before I unzipped it.
More on this solution here and here
I've seen this where the "network location" is mentioned and you are using a DLL locally (i.e. not remotely) - but it was copied from a remote location (e.g. internet file share site).
The trick in this case was I suspected the DLL was blocked due to the streams concept, but the explorer UI properties dialog did not show the "unblock" button.
To work around this, I used the sysinternals tool "streams" (found here: Streams download) like so:
streams <your dll> -> view stream streams -d <your dll> -> delete the stream data on a file
There's also a recurse option with -r if you want to target a group of files.
I hope this helps someone else - it was tricky because the UI didn't show it was blocked, but it clearly was (perhaps due to some other security measure here).
This solution also means you don't need to adjust the loadFromRemoteSources flag, as that is quite a broad stroke.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With