Here is the following question in Factoy when I reuse the abstract Factory + reflection refactoring Room:
Went to the Internet to check the information, found that this is a very common problem, it appears mainly because of two kinds of reasons:
The first type:
Error loading DLL path. The workaround is to adjust the path of the D layer build DLL into the Bin folder of the UI. The following figure:
One of the principles of reflection is that everything is centered on the DLL name in the Bin folder of the UI layer, white, a DLL is a class library. The reflection I understand is a string of stitching that makes up the name of the class to instantiate. When using reflection to load a class, it is found by default from the bin in the UI layer, so the DLL for the D-tier class is generated under the Bin folder of the UI, so that it can be loaded successfully.
The second type:
Is the expansion of the first exception with the exception name: Failed to load the file or assembly "DAL" or one of its dependencies. An attempt was made to load a program that is not properly formatted. This exception is mainly due to the fact that the referenced project. NET version differs from the starting frame. If the operating system is 64-bit, but the published program references some 32-bit DDL, there is a compatibility issue.
Solution One: If you are a 64-bit machine, IIS ——-application pool-Advanced settings-enable 32-bit applications: true.
Solution Two: Modify project Properties--build--target platform (e.g., x86\x64)