Vb. NET failed to load a file or assembly "XXX" or one of its dependencies.

Source: Internet
Author: User
Tags reflection

when the computer room is reconstructed to seven layers, the following error occurs when the runtime really tortured himself half a day, on the internet to find a lot of ways, in addition to a way not to make, the others have tried, or not, in fact, in this period, see Shige a blog, is about this problem, but I feel a little understand, in fact, I did not look carefully, When I saw his blog about this issue, wrote an article, give a person a very difficult feeling, see his blog inside the design to a lot of folders feel see have not seen, so give up, but in fact, the folder in their own projects, did not go to point, it wasted a lot of time, and finally still use Shige method to solve.

The source of the problem:

first, the problem appears in the reflected code, which is

Return CType (Assembly.Load (AssemblyName). CreateInstance (ClassName), Login.IDAL.ISelectUserAccess)
cause of the problem: (Shige blog here)

1. The filename is inconsistent with the DLL file name at load time.
2:. DLL file does not exist at all, that is, loss occurs.

2:. DLL file does not exist at all, that is, loss occurs.

3.: Loading DLL path error, that is, DLL file exists, but the loading path is incorrect Solution:

First make sure your code is accurate, mainly to see if the parameters are correct

that is, you can find the corresponding assembly name, namespace


let's get acquainted.. dll file: DLL is a dynamic link library file, is an executable file that itself is a library that contains code and data that can be used by multiple programs at the same time (not all files that can be run are called executables, some may be executed, and some programs are bound together and run when you click), seemingly Looks like the execution file). DLLs have two benefits @1: You can enable a process to invoke functions that do not belong to its executable code; @2: helps you share data and resources.

after making sure that the parameters are correct, you find that the Bebug folder underneath the U-Layer Bin folder has the. All file in the other layers except for the. dll file in the layer. From Shige's blog, I Learned:. NET class is the default to find the. dll file for the assembly to load from the bin file of this assembly. So the startup project under the Bin folder to have other programs of the. dll file (I find in the Bin folder of each program, found a rule, is that you this program refers to who, in the bin below the program has a reference program . dll files, including indirect references, that is, the U-level reference façade layer, the façade layer refers to layer B, so there is a B-level. dll file in the U layer, which is referenced by automatically copying the. dll when this assembly changes. So I manually copied the D-level. dll file to the U layer, at which point the problem was resolved, but another error occurred while running:

just now I manually dragged the file to another folder, the solution to this problem is in the D-tier build output path, using browse to add the U-level. dll file in


Reflection: Provide a programmatic way, in the program run period of the components of the net can be related to the content of the computer room toll system with the purpose of reflection: the replacement of the database

This is an online search on the vb.net reflection mechanism of understanding:http://www.cnblogs.com/pangblog/archive/2013/08/22/3275579.html

Reflection is still studying ...

" Summary "

in fact, sometimes is always intimidated by the problem, such as the beginning of the search to Shige's blog, but did not have the patience to look down, to search other methods, the results can be imagined, if the beginning of my patience to look down, to my folder more points, the problem is solved. This verifies the teacher's words: To do it, this problem to say to find on the line, that is to do. To find out more about a program or application, go a little bit more. If you don't want to move your head, you'll spend more time.

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.