views:

151

answers:

2

If I have a project with an App.Config, and when I compile it I get a file next to my DLL called [myproject].dll.config which contains the contents of the projects App.Config.

If I want to reference [myproject].dll from another project, do I need to copy the .config file as well? Can the App.Config file be compiled into the DLL so all that is required is the DLL itself?

+1  A: 

When you actually run your app, the only config file it will read is the YourExeName.exe.config. It won't look at any yourdll.dll.config files. You need to put everything that needs to be used into the YourExeName.exe.config file.

However, .net settings will automatically compile the default into the .dlls so you don't need to worry about them unless you want to set them to something other than the default you specified, but connection strings or anything like that will need to be placed in yourexe.exe.config.

Simon P Stevens
+1  A: 

The App.Config is a separate entity that cannot be compiled into the DLL. What you can do, however, is load the dll in a separate domain and associate the config file with it there. I blogged about this here.

Pete OHanlon