Consuming DLL which Consumes EntLib3.1

Topics: Building and extending application blocks, Caching Application Block , Cryptography Application Block, Data Access Application Block, Enterprise Library Core, Exception Handling Application Block, General discussion, Logging Application Block, Policy Injection Application Block, Pre-release discussions, Security Application Block, Validation Application Block
Apr 9, 2008 at 12:05 AM

I have a DLL which uses the EntLIb 3.1 library. Lets call it someAssembly.dll

Outide of that solution, I have a C# application which consumes the someAssembly.dll. I reference in someAssembly.dll into my C# application, I also have to maually copy over someAssembly.dll.config.

HOWEVER, when I run my C# application, I'm getting errors back from someAssembly stating that it's not able to find the config file. IF, I create a new app.config file for my C# application, then copy all the someAssembly.dll config data into that, then my app will run fine. It can find the config file.

However, this is not going to work for me. How can I get my C# app to load someAssemembly.dll and have someAssembly.dll read the correct config file, which again in this case would be someAssembly.dll.config ????

Apr 14, 2008 at 8:11 PM

That is not the way configuration works for .NET applications, at least not by default. Configuration files are not owned by assemblies, but by apps. You can approximate the usage you want by defining a new file configuration source in your app's configuration file pointing to your assembly's config file. If you only need to do this for a single assembly, you can set the new config source as the default and use the standard static facades, but if you need to do this for more than one assembly then you'll need to use this configuration source explicitly and you won't be able to use the static facades like Logger. This is not arbitrary: keep in mind that "static" means shared in an AppDomain, not scoped to a single assembly

Aug 4, 2010 at 7:42 PM

I realize that I might be necroing here a bit but I wanted to clarify a situation.

We have encapsulated logging capabilites using the Enterprise Library 5 logging facility into a DLL and added an app.config with all the pertinent loggingConfiguration XML as produced by the Enterprise Library Configuration Editor.  The hope is/was to then reference the DLL from any number of independent executables (Console Apps, Windows Services, Form Apps, etc.) without having to specify the configuration information from each app but that anyone using the DLL would use it's configuration information.

My experiments and the above statements indicate this was/is not possible.  True?  Anyway to work around this?


Aug 5, 2010 at 6:57 AM


Actually I believe what Fernando mentioned from the above post is that you can utilize the file configuration source to be able to read from the assembly's config file. He has also pointed out that if you would implement this in more than one assembly then you won't be able to use the standard static facades. Somewhat I assumes your question seems also related to this thread which also points to this blog on how you'll be able to use external config files. Hope this helps.

If this is not the case with your question please us know.

Gino Terrado
Global Technology and Solutions
Avanade, Inc.

Aug 10, 2010 at 9:24 PM

Thanks for the link - that solved my problem.