asp.net-mvc-3 – 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项目中的任何页面时,我都会收到以下错误:

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

并且源错误指向此行:

Line 91:         <clear />
Line 92:         <add name="MvcSiteMapProvider"
Line 93:              type="MvcSiteMapProvider.DefaultSiteMapProvider, MvcSiteMapProvider"

为什么我收到此错误?

我最终发现自己的问题是什么. MvcSiteMap提供程序库使用反射Activator.Createinstance()方法调用您在站点地图文件中设置的提供程序.如果提供程序的格式不正确,则Activator将失败并显示上述消息.

例如,visibilityprovider的站点地图中的值应为“fullqualifiednamespace.ProviderClass,AssemblyName”.

e.g. "MyApplicationNamespace.AuthenticationVisibilityProvider, MyApplication"
相关文章
相关标签/搜索