"Cocould not load file or assembly '*****'" exception occurs when plug-in applications are developed using. net.

Source: Internet
Author: User

Recently, when using. Net to develop plug-in applications, the plug-in file (. dll) dynamically loaded during runtime is not in the framework master.Program(.Exe) directory, so the "cocould not load file or assembly '*****'" exception occurred during running.

This reminds me of the previous method to solve similar errors in Java programs: adding the corresponding directory to the class path or path directory can solve this problem, which is caused by the failure of the Java Virtual Machine to find the path, adding a search path to the corresponding location can solve this problem.

I found a piece of information and found that this problem can be solved as follows in. Net: Before loading the Assembly, add the followingCode

Appdomain. Currentdomain. appendprivatepath (PATH );// Directory of the Assembly

Supplement:Msdn recommends discarding appendprivatepath (...) Instead, you can set the privatebinpath attribute of the setupinformation attribute (appdomainsetup type) of appdomain. However, I cannot set this attribute successfully.L

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.