views:

40

answers:

2

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.

+1  A: 

Do you have a reference to System.Configuration? It's not added to .NET projects by default.

Steve Danner
A: 

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!

JerryK