Assembly failure during DLL loading

Source: Internet
Author: User

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.

1, refer to https://msdn.microsoft.com/en-us/library/dd409252 (vs.100). aspx for resolution, configure App. Config to complete

<configuration>   <runtime>      <loadfromremotesources enabled= "true"/>   </runtime ></configuration>

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);

3, The assembly load method has a number of overloads that can be used with a load function with a parameter of byte[]. 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"



Assembly failure during DLL loading

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.