views:

58

answers:

2

Hello I'm getting this error:

Compiler Error Message: CS0118: 'Configuration' is a 'namespace' but is used like a 'type' Configuration myWebConfig = WebConfigurationManager.OpenWebConfiguration("~/");

This code has been in place for 5+ months without this issues, only today after adding this sitemap code do I have this issue.

<siteMap defaultProvider="ExtendedSiteMapProvider" enabled="true">
            <providers>
                <clear/>
                <add name="ExtendedSiteMapProvider" type="Configuration.ExtendedSiteMapProvider" siteMapFile="Web.sitemap" securityTrimmingEnabled="true"/>
            </providers>
        </siteMap>

I tried adding "System.Web." before the "Configuration ", but that did not work either:

System.Web.Configuration myWebConfig = WebConfigurationManager.OpenWebConfiguration("~/");

Error 1 'System.Web.Configuration' is a 'namespace' but is used like a 'type'

+1  A: 

System.Configuration.Configuration instead of System.Web.Configuration

        // Get the configuration object for a Web application
        // running on the local server. 
        System.Configuration.Configuration config =
            WebConfigurationManager.OpenWebConfiguration("/~") 
            as System.Configuration.Configuration; 
volody
A: 

The error you're being given is correct, System.Web.Configuration is a namespace and not a type and so can not be instantiated.

You want to use the type System.Web.Configuration.WebConfigurationManager if my memory serves me correctly.

EDIT: MSDN

Fishcake