ConfigurationManager Class not exist on .NET 4.5 F

2019-04-17 19:25发布

问题:

I just start working with .NET Framework 4.5 of C#. Am using Windows Form Application. I have do the needed imports such as :

using System.Configuration;

But actually the ConfigurationManager class seems that it is not exits. I have tried to use ConfigurationSettings instead , but Visual Stdio telling me that it is obsolete and replaced by ConfigurationManager !

This is chunk of code related to the problem :

Int32.Parse StartingMonth = int.parse(ConfigurationManager.AppSettings["StartingMonthColumn"]);

So , could you please help me ?

回答1:

  1. Make sure that you add System.Configuration.dll to the project. If you already added it, try to remove and add it again.
  2. Put the cursor on ConfigurationManager then press ctrl+., and see what it suggests you.


回答2:

RightClick on project -> Add-> Reference...-> Assemblies-> Framework Select the System.Configuration (checked) Should solve the problem.



回答3:

It is because of reference , I just restarted the project after adding the reference and it is working OK :)



回答4:

ConfigurationManager is present in System.Configuration namespace but it need System.Configuration assembly in your project.



回答5:

If you are unable to find the reference here is the correct path

"C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b03f5f7f11d50a3a"

Go to the Add reference and select the browser option and go to the above link. Then you can add the System.Configuration.dll



标签: c# .net .net-4.5