This article is a mirror article of machine translation, please click here to jump to the original article.

View: 50236|Reply: 3

[Source] C# puts reference library DLLs into subfolders via probing

[Copy link]
Posted on 2020-11-10 17:46:35 | | | |
Demand:

There are three types of DLLs in the project, too many, and messy. How to put them under three subdirectories
Like what:
Dev is placed in the directory Devexpress
Place your reference library project in the directory Lib
Third-party DLLs are placed in the directory Oth

When we are developing on a large project, we will find that there will be a lot of dlls referenced by the project, and I want to put different dlls in different folders according to different functions.

Example:

We net2 is a console project, it will reference the ClassLibrary4 class library, the compiled application and dll will be in the same directory, I want to put ClassLibrary4.dll under the test folder under the program directory, we put it directly in, it will throw an exception:

Unhandled Exception: System.IO.FileNotFoundException: Failed to load a file or assembly "ClassLibrary4, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" or one of its dependencies. The system cannot find the specified file.
   In net2. Program.Main(String[] args)

Solution

Edit the net2.exe.config file and add the probing settings as follows:

If there are two different dlls that need to be put in two different folders, insideUse semicolons to indicate different foldersFor example:


ClassLibrary4 Code:

net2 code:


Try running the program as shown below:


Remark:You can write a bat script and put the library dll into a subdirectory through the time after the assembly is generated

(End)






Previous:Be wary of System.Environment.CurrentDirectory to get the current directory
Next:. .NET MySQL Connector Conflicts DbProviderFactories (.NET MySQL Connector Conflicts DbP...
 Landlord| Posted on 2020-11-10 18:18:44 |
If the C++ dll is placed in the program subdirectory, it can be set by adding environment variables

For example:

Put the dll under the test directory



Posted on 2021-7-16 22:42:52 |
Learned。。。。。。
Posted on 2023-2-25 21:18:42 |
I really hope this is what I'm looking for
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com