Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

app.config for a class library

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.

like image 811
logeeks Avatar asked Apr 15 '11 09:04

logeeks


People also ask

Can we have app config in class library?

No, class libraries can hold setting files, but their values will be defined in the application configuration (web. config, app.

How do I add a class library in Windows app?

Right-click on the solution in Solution Explorer and select Add > New Project. On the Add a new project page, enter library in the search box. Choose C# or Visual Basic from the Language list, and then choose All platforms from the Platform list. Choose the Class Library template, and then choose Next.

How read app config file in C# Windows application?

Add the App. config file to your project. After creating a . NET Framework project, right-click on your project in Solution Explorer and choose Add > New Item. Choose the Application Configuration File item and then select Add.


1 Answers

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.

like image 153
Andrew Barber Avatar answered Sep 27 '22 19:09

Andrew Barber