0

I have an additional config file for my library. I use it to config log4net. So library can configure log4net. I add reference to the library to another project in my solution and i need to make VS copy not only .dll file, but also .config file. How can i do it? Thanks.

Yola
  • 18,496
  • 11
  • 65
  • 106
  • 2
    .NET class libraries generally don't have .config files. [Tell me more](http://stackoverflow.com/questions/594298/c-sharp-dll-config-file) –  May 06 '15 at 08:39
  • How about setup your own Nuget server and create packages for these library – Edward N May 06 '15 at 08:42

2 Answers2

2

You have to include the configuration section for log4net in the app.config file of the main project you are referencing the library...

You can also take a look here...

Community
  • 1
  • 1
Peter Schneider
  • 2,879
  • 1
  • 14
  • 17
  • and if i will change library config? – Yola May 06 '15 at 08:45
  • 2
    Then you change it in the app.config? – Peter Schneider May 06 '15 at 08:46
  • Rather than having log4net config sections in multiple libraries, create one log4net config file and include it in app.config as shown [here](http://stackoverflow.com/questions/480538/use-xml-includes-or-config-references-in-app-config-to-include-other-config-file) – Panagiotis Kanavos May 06 '15 at 08:48
  • That is a lot to ask, if it were possible to add relative link to library config from app config, that would be nice though. – Yola May 06 '15 at 08:48
  • 1
    You can load a configsection from a separate file, I just posted the link in the previous comment. Be careful though, you can include specific config sections, not entire config files – Panagiotis Kanavos May 06 '15 at 08:49
  • You approach is good, but in my very special case, i need it for test app for VS visualizer, i will use my approach. Thanks. Anyway +1. – Yola May 06 '15 at 08:50
1

As Micky pointed out assemblies don't have config files, but you could use "Add existing file" and select "Add as Link" and then set "Copy To Output Directory" To "Copy always" this way the file should be copied to the output directory.

Peter
  • 37,042
  • 39
  • 142
  • 198