简体   繁体   中英

Can't programmatically access WebConfigurationManager in VS 2012

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?

In Object Browser, simply browsing System.Web will allow you to drill into all of System.Web.dll 's namespaces (eg 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 (ie 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM