Access Web.config from another Project.
Many of our .Net web app solutions have multiple class library projects and in those projects we want to access various app settings in a central web.config housed in the web app project.
You will find that simply accessing the Configuration Manager in a class library will not compile.
Huh? But it works just fine in my web project. Even ReSharper can't help me here. That's because the assembly required for the Configuration Manager doesn't ship with Class Library projects out of the box.
To fix the problem add the System.Configuration assembly to your project.
If you have ReSharper, it will now be able to help you by automatically importing the namespace. Otherwise, just add it yourself manually.
Hope this helps!
Published: 12/15/16
You will find that simply accessing the Configuration Manager in a class library will not compile.
Huh? But it works just fine in my web project. Even ReSharper can't help me here. That's because the assembly required for the Configuration Manager doesn't ship with Class Library projects out of the box.
To fix the problem add the System.Configuration assembly to your project.
If you have ReSharper, it will now be able to help you by automatically importing the namespace. Otherwise, just add it yourself manually.
Hope this helps!
Published: 12/15/16
Comments
Post a Comment