app.config for a class library

logeeks picture logeeks · Apr 15, 2011 · Viewed 102.9k times · Source

I cannot see a app.config file generated for a class library by the VS2008 wizard. In my research I found that in an application only one app.config exists.

Is it a bad thing to add an app.config manually to a class library or are there any other methods which will serve the purpose of an app.config in class library?

I need to store log4net config information inside the app.config file.

Answer

Andrew Barber picture Andrew Barber · Apr 15, 2011

You generally should not add an app.config file to a class library project; it won't be used without some painful bending and twisting on your part. It doesn't hurt the library project at all - it just won't do anything at all.

Instead, you configure the application which is using your library; so the configuration information required would go there. Each application that might use your library likely will have different requirements, so this actually makes logical sense, too.