Can't programmatically access WebConfigurationManager in VS 2012

141 views Asked by At

In my VS 2012 project, I have a reference to System.Web.

If I browse System.Web in Object Brower, it contains System.Web.Configuration.WebConfigurationManager; but in my code, System.Web only shows me AspNetHostingPermission, AspNetHostingPermissionAtribute, AspNetHostingPermissionLevel...

In VS2010 I don't have this problem.

Any suggestions?

1

There are 1 answers

1
J0e3gan On

In Object Browser, simply browsing System.Web will allow you to drill into all of System.Web.dll's namespaces (e.g. System.Web.Configuration).

In code, however:

  • You need a using statement (assuming C#) for each namespace in the assembly before IntelliSense will display the types within it (or the code can reference them).
  • Your project's target framework (in the project's properties) also needs to be set correctly.

using Statement

In the code file in question, it sounds like you may then have...

using System.Web;

...but not:

using System.Web.Configuration;

In this case, add using System.Web.Configuration; to the code file.

Target Framework

Another possibility is that your VS 2012 project's target framework (i.e. Application > Target framework in the project's properties) is incorrectly set to a .NET Framework client profile – for example...

.NET Framework 4 Client Profile

...instead of:

.NET Framework 4