Error phenomena:
An error occurred while reading the plugin: "An attempt was made to load an assembly from a network location in an earlier version of the. NET Framework, which results in sandboxed processing of the assembly." The. NET Framework for this release is not enabled by default for CAS policy, so this load can be dangerous. If this load is not sandboxed for the assembly, enable the loadfromremotesources switch. For more information, see http://go.microsoft.com/fwlink/?LinkId=155569. ”
Cause of error: A security mechanism that references an external dll,dotnet in a project prevents the loading of a assembly on a local network or on the Internet.
Method 1, refer to https://msdn.microsoft.com/en-us/library/dd409252 (vs.100). aspx for resolution, configure App. Config to finish <configuration>
<runtime>
<loadfromremotesources enabled= "true"/> </runtime></configuration>
Method The 2,assembly class has a static function unsafeloadfrom, which does not perform some security checks when loading a assembly. The load DLL statement was modified to:
String dll = @ "Z:\test.dll";
Assembly a = assembly.unsafeloadfrom (DLL);
Method 3, assembly's Load method has a lot of overloads, you can use one of the parameters of the byte[] load function. The code is as follows:
String dll = @ "Z:\test.dll";;
byte[] assemblybuffer = file.readallbytes (DLL);
Assembly a = assembly.load (assemblybuffer);
"Original http://blog.csdn.net/studying/article/details/6663627"
C # fails when loading an assembly with Assembly