Accessing App.Config Values In Class Library Not Working In C#
In a project that we are working with involves several class libraries. And one of them involves setting/getting the connection string. We simply added an application config file with the connection string in it. However, accessing the key/value of connection string returns null.
One possible solution is to add a Settings file in the class library where you can set the connection string. And to access the connection string value, refer to the code below:
Here's a similar post regarding Settings File:
Setting app.config in ASP.NET
Cheers!
One possible solution is to add a Settings file in the class library where you can set the connection string. And to access the connection string value, refer to the code below:
//Settings is the Settings File. //SalesConnection is the Name of the connection string return new Settings().SalesConnection;
Setting app.config in ASP.NET
Cheers!
Comments
Post a Comment