开发者

MvcSiteMapProvider and web.config: Parser Error Message: Value cannot be null

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 开发者_Go百科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?


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".

e.g. "MyApplicationNamespace.AuthenticationVisibilityProvider, MyApplication"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜