我得到了这个错误:
编译器错误消息: Configuration:‘CS0118’是一个‘命名空间’,但它的用法类似于‘CS0118’配置myWebConfig = WebConfigurationManager.OpenWebConfiguration("~/");
这个代码已经存在5+几个月了,没有这个问题,直到今天添加了这个网站地图代码,我才有这个问题。
<siteMap defaultProvider="ExtendedSiteMapProvider" enabled="true">
<providers>
<clear/>
<add name="ExtendedSiteMapProvider" type="Configuration.ExtendedSiteMapProvider" siteMapFile="Web.sitemap" securityTrimmingEnabled="true"/>
</providers>
</siteMap>我试着加上“System.Web”在“配置”之前,但这也不起作用:
System.Web.Configuration myWebConfig = WebConfigurationManager.OpenWebConfiguration("~/");错误1 'System.Web.Configuration‘是一个'namespace’,但其使用方式与'type‘类似
发布于 2010-05-16 12:52:12
用System.Configuration.Configuration代替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; 发布于 2010-05-16 12:52:49
你得到的错误是正确的,System.Web.Configuration是一个命名空间而不是一个类型,所以不能被实例化。
如果我没记错的话,您想使用System.Web.Configuration.WebConfigurationManager类型。
编辑:MSDN
https://stackoverflow.com/questions/2842562
复制相似问题