Reference to ConfigurationManager class generates compile errors in .net 4.5

0
=
0
+
0
No specific Bitcoin Bounty has been announced by author. Still, anyone could send Bitcoin Tips to those who provide a good answer.
0

I'm using this namespace:

using System.Configuration;

and here is my code:

private static string _smtpServer = ConfigurationManager.AppSettings["SMTPServer"];

However I am getting a compilation error saying that "ConfigurationManager" does not exist.

Thanks

1 Answer

1
=
0
=
$0
Internet users could send Bitcoin Tips to you if they like your answer!

Including "using" statement is not enough. In order for compiler to find your target class (ConfigurationManager), you need to REFERENCE the assembly that contains that class definition. In your case, this assembly is known as "System.Configuration".

To add a reference to the above mentioned assembly:

  1. Right click on your project;
  2. Click to "Add Reference";
  3. Select the .NET Tab;
  4. Select System.Configuration

This should make it work. Cheers!

SEND BITCOIN TIPS
0

Too many commands? Learning new syntax?

FavScripts.com is a free tool to save your favorite scripts and commands, then quickly find and copy-paste your commands with just few clicks.

Boost your productivity with FavScripts.com!

Post Answer