Unable to use C# ConfigurationManager
Solution 1
Do you have a reference to System.Configuration
? It's not added to .NET projects by default.
Solution 2
I was having the same issue.
It took me a little while to figure out that adding the reference is not adding the using. I had to right-click the project and select Add Reference, then pick System.Configuration in the .NET tab.
Worked like a charm!
Solution 3
Ensure that the actual project
you're working in has a reference to System.Configuration
. I was working in a data access project, not the presentation layer's project. So I was getting a bit confused because I had thought I had a reference, but in reality the data project
was missing the reference.
Paul Michaels
I've been a programmer for most of my life. I have an interest in games, mobile and tablet development, along with message queuing, and pretty much anything that provides an elegant solution to a problem, technical or otherwise. I like learning new technology and finding new ways to use the old. I blog about my experiences here. You can read about me, or contact me on Linked in here.
Updated on July 19, 2022Comments
-
Paul Michaels almost 2 years
I have the following code:
using System.Configuration; namespace test { public partial class MyService : ServiceBase { public static ReadConnectionStrings() { ConnectionStringSettingsCollection connections = ConfigurationManager.ConnectionStrings;
However, it doesn’t recognise ConfigurationManager. I took this code directly from here
So I’m clearly missing something, but can’t identify what.
-
Somachr about 7 yearsWhat if this is shared project?