What is the purpose of a .config file to build a .DLL library?

This question was caused by another issue that I was dealing with. There is a managed library MyAssembly.dll designed for .NET 4.0. It has its own MyAssembly.dll.config file with some <bindingRedirect> instructions. I believe that the .config file was generated either by the compiler or the NuGet package manager, since I did not create it manually.

The fact is that binding instructions are ignored when the DLL is loaded by the client application ( RegAsm.exe in my case, but I also checked it with a simple .NET console application). I had to transfer them from the DLL.config file to the application .config file of the client EXE application, which will be picked up by .NET runtime and will be correctly resolved.

Question: What is the purpose of the .config file to build a managed library (.DLL) in general? . Does he still participate in the download process of the library collection?

+6
source share
1 answer

There is no β€œgoal." The library consumer can copy the settings from .dll.config to their own .exe.config or web.config.

The .dll.config file simply provides Visual Studio for storing the library configuration.


Note that in general, one library can be used by several callers, each with a different configuration. In fact, it does not make much sense, in general, for the library to dictate the settings.

+5
source

Source: https://habr.com/ru/post/958612/


All Articles