MvcSiteMapProvider and web.config: error message Parser: 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 a link to the MvcSiteMap DLL project, a Sitemap called mvc.sitemap. Page namespaces also look like this:

  <pages> <namespaces> ... <add namespace="MvcSiteMapProvider.Web.Html"/> <add namespace="MvcSiteMapProvider.Web.Html.Models"/> </namespaces> </pages> 

However, whenever I look at any page in my MVC3 project, I get the following error:

Configuration Error Description: An error occurred while processing the configuration file necessary to service this request. Please read the specific error details below and modify the configuration file accordingly.

Parser error message: value cannot be zero. Parameter Name: type

And the original error points to this line:

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

Why am I getting this error?

+4
source share
1 answer

In the end, I found out what the problem is. The MvcSiteMap provider library uses the Activator.Createinstance () reflection method to invoke the provider that you configured in the Sitemap. If the provider format is incorrect, the activator fails with the above message.

For example, the value in the sitemap for visibilityprovider should be "fullqualifiednamespace.ProviderClass, AssemblyName".

 eg "MyApplicationNamespace.AuthenticationVisibilityProvider, MyApplication" 
+7
source

Source: https://habr.com/ru/post/1346744/


All Articles