Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

App config in Class library C#

Tags:

c#

wpf

I have a wpf application which is using a dll of a class library. I am unable to access the app.config value in the class library

How I'm trying to access app.config:

ConfigurationSettings.AppSettings["conStr"].ToString();

this is returning a null value using System.Configuration is also added .

like image 258
VJL Avatar asked Nov 27 '22 14:11

VJL


1 Answers

Why don't you just put that value in the Main Project ?

If you're calling the class library from the Main Project. Then the code in the class library uses the AppConfig defined inside the main project.

It is a common practice to have the connection string in the AppConfig for the Main Project and not inside the Class Library.

like image 197
Zein Makki Avatar answered Dec 10 '22 02:12

Zein Makki