locked
C# 4: Cant find the ConfigurationManager RRS feed

  • Question

  • I am trying to read the values from App.config file in my windows application using system.Configuration. When I use following code, I am getting a warning message

    String Connection_String = ConfigurationSettings.AppSettings.Get("ProductionConnStrUserID").ToString();
    

    Warning message:

    'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: '"This method is obsolete, it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings"'  

    However, I cannot find the 'ConfigurationManager' in system.Configuration

    I faced the same problem when I was using VB.Net and solved that by adding System.Configuration.dll by browsing the specific dll in the .Netframework\4.0 directory. However, this solution is not working in C# 4 and still getting that warning message (It is warning message only, not any error)

    Any help on this?

     

     


    Dreaming a world without any war in anywhere
    Wednesday, January 12, 2011 6:15 PM

Answers

  • Double (or triple) check your references - ConfigurationManager is definitely in the System.Configuration reference.  If that doesn't seem right, remove the reference and re-add it just in case.
    • Marked as answer by Rajeeshun Wednesday, January 12, 2011 7:13 PM
    Wednesday, January 12, 2011 6:44 PM

All replies

  • have you add a reference of System.Configuration to your project?

    Add a reference to System.Configuration.dll, and you should be able to use the System.Configuration.ConfigurationManager.

    Wednesday, January 12, 2011 6:18 PM
  • have you add a reference of System.Configuration to your project?

    Add a reference to System.Configuration.dll, and you should be able to use the System.Configuration.ConfigurationManager.


    I did...It is showing all other objects/methods from the System.Configuration BUT Cannot find ConfigurationManager. It looks like a bug in C# 4 (Or VS2010)

     


    Dreaming a world without any war in anywhere
    Wednesday, January 12, 2011 6:32 PM
  • Double (or triple) check your references - ConfigurationManager is definitely in the System.Configuration reference.  If that doesn't seem right, remove the reference and re-add it just in case.
    • Marked as answer by Rajeeshun Wednesday, January 12, 2011 7:13 PM
    Wednesday, January 12, 2011 6:44 PM
  • Double (or triple) check your references - ConfigurationManager is definitely in the System.Configuration reference.  If that doesn't seem right, remove the reference and re-add it just in case.


    That resolved the problem

     

    Thanks


    Dreaming a world without any war in anywhere
    Wednesday, January 12, 2011 7:13 PM
  • What I told u? :)

    Glad you salved it.

    bye,

    Mitja

    Wednesday, January 12, 2011 7:20 PM
  • What I told u? :)

    Glad you salved it.

    bye,

    Mitja


    The difference is, I removed the reference and re-added again (as Cabadam said)

     


    Dreaming a world without any war in anywhere
    Wednesday, January 12, 2011 7:29 PM
  • Removing and re-adding the reference seemed to work for me, I recall I encountered this recently

    Friday, June 9, 2017 8:52 AM