MvcSiteMapProvider 和 web.config:解析器错误消息:值不能为 null
在我的 web.config 文件中,我有:
<siteMap defaultProvider="MvcSiteMapProvider" enabled="true">
<providers>
<clear />
<add name="MvcSiteMapProvider"
type="MvcSiteMapProvider.DefaultSiteMapProvider, MvcSiteMapProvider"
siteMapFile="~/Mvc.Sitemap"
securityTrimmingEnabled="true"
cacheDuration="5"
enableLocalization="false"
scanAssembliesForSiteMapNodes="true"
excludeAssembliesForScan=""
includeAssembliesForScan=""
attributesToIgnore=""
nodeKeyGenerator="MvcSiteMapProvider.DefaultNodeKeyGenerator, MvcSiteMapProvider"
controllerTypeResolver="MvcSiteMapProvider.DefaultControllerTypeResolver, MvcSiteMapProvider"
actionMethodParameterResolver="MvcSiteMapProvider.DefaultActionMethodParameterResolver, MvcSiteMapProvider"
aclModule="MvcSiteMapProvider.DefaultAclModule, MvcSiteMapProvider"
siteMapNodeUrlResolver="MvcSiteMapProvider.DefaultSiteMapNodeUrlResolver, MvcSiteMapProvider"
siteMapNodeVisibilityProvider="ekmProspector.web.SiteMapProviders.AuthenticatedVisibilityProvider, ekmProspector"
siteMapProviderEventHandler="MvcSiteMapProvider.DefaultSiteMapProviderEventHandler, MvcSiteMapProvider"
/>
</providers>
</siteMap>
我还有对 MvcSiteMap 库 dll 的项目引用,即名为 mvc.sitemap 的站点地图。 页面命名空间也看起来像:
<pages>
<namespaces>
...
<add namespace="MvcSiteMapProvider.Web.Html"/>
<add namespace="MvcSiteMapProvider.Web.Html.Models"/>
</namespaces>
</pages>
但是,每当我浏览到 MVC3 项目中的任何页面时,我都会收到以下错误:
配置错误描述:An 处理过程中发生错误 所需的配置文件 服务此请求。请查看 下面的具体错误详细信息和 修改你的配置文件 适当地。
解析器错误消息:值不能为 无效的。参数名称:类型
源错误指向这一行:
Line 91: <clear />
Line 92: <add name="MvcSiteMapProvider"
Line 93: type="MvcSiteMapProvider.DefaultSiteMapProvider, MvcSiteMapProvider"
为什么我会收到此错误?
In my web.config file I have:
<siteMap defaultProvider="MvcSiteMapProvider" enabled="true">
<providers>
<clear />
<add name="MvcSiteMapProvider"
type="MvcSiteMapProvider.DefaultSiteMapProvider, MvcSiteMapProvider"
siteMapFile="~/Mvc.Sitemap"
securityTrimmingEnabled="true"
cacheDuration="5"
enableLocalization="false"
scanAssembliesForSiteMapNodes="true"
excludeAssembliesForScan=""
includeAssembliesForScan=""
attributesToIgnore=""
nodeKeyGenerator="MvcSiteMapProvider.DefaultNodeKeyGenerator, MvcSiteMapProvider"
controllerTypeResolver="MvcSiteMapProvider.DefaultControllerTypeResolver, MvcSiteMapProvider"
actionMethodParameterResolver="MvcSiteMapProvider.DefaultActionMethodParameterResolver, MvcSiteMapProvider"
aclModule="MvcSiteMapProvider.DefaultAclModule, MvcSiteMapProvider"
siteMapNodeUrlResolver="MvcSiteMapProvider.DefaultSiteMapNodeUrlResolver, MvcSiteMapProvider"
siteMapNodeVisibilityProvider="ekmProspector.web.SiteMapProviders.AuthenticatedVisibilityProvider, ekmProspector"
siteMapProviderEventHandler="MvcSiteMapProvider.DefaultSiteMapProviderEventHandler, MvcSiteMapProvider"
/>
</providers>
</siteMap>
I also have project reference to the MvcSiteMap library dll, a sitemap named mvc.sitemap.
The pages namespaces also look like:
<pages>
<namespaces>
...
<add namespace="MvcSiteMapProvider.Web.Html"/>
<add namespace="MvcSiteMapProvider.Web.Html.Models"/>
</namespaces>
</pages>
However, whenever I browse to any page in my MVC3 project I get the following error:
Configuration Error Description: An
error occurred during the processing
of a configuration file required to
service this request. Please review
the specific error details below and
modify your configuration file
appropriately.Parser Error Message: Value cannot be
null. Parameter name: type
And the source error is pointing to this line:
Line 91: <clear />
Line 92: <add name="MvcSiteMapProvider"
Line 93: type="MvcSiteMapProvider.DefaultSiteMapProvider, MvcSiteMapProvider"
Why am I getting this error?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我最终自己发现了问题所在。 MvcSiteMap 提供程序库使用反射 Activator.Createinstance() 方法来调用您在站点地图文件中设置的提供程序。如果提供程序的格式不正确,Activator 将失败并显示上述消息。
例如,可见性提供程序的站点地图中的值应为“fullqualifiednamespace.ProviderClass, AssemblyName”。
I eventually found out myself what the problem was. The MvcSiteMap provider library uses the reflection Activator.Createinstance() method to call into the provider you set-up in the sitemap file. If the format of the provider is incorrect, Activator fails with the above message.
For example, the value in the sitemap for a visibilityprovider should be "fullqualifiednamespace.ProviderClass, AssemblyName".