Sitemap troubles - Unable to load one or more of the requested types.

Jun 22, 2010 at 3:17 AM
Edited Jun 22, 2010 at 5:24 PM

Hi, I'm trying to implement the version 2 sitemap provider. 

my web.config looks like

 <siteMap defaultProvider="MvcSiteMapProvider" enabled="true">
      <providers>
        <clear />
        <add name="MvcSiteMapProvider"
             type="MvcSiteMapProvider.DefaultSiteMapProvider, MvcSiteMapProvider"
             siteMapFile="~/Content/sitemap/udaf.sitemap"
             />
      </providers>
    </siteMap>

I add this to the sitemap file

<?xml version="1.0" encoding="utf-8" ?>
<mvcSiteMap xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-2.0" enableLocalization="true">
  <mvcSiteMapNode title="Home" controller="Home" action="Index" changeFrequency="Always" updatePriority="Normal">
    <mvcSiteMapNode title="Register" controller="Register" action="Index" />
  </mvcSiteMapNode>
</mvcSiteMap>

and get the error below.  Is this because I'm using castle windsor ioc?

I also tried adding [MvcSiteMapNodeAttribute(Title = "Register", ParentKey = "Home")] to my public ActionResult Index() method and nothing happens.

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Source Error:

Line 124:    <div class="clear">
Line 125: </div>
Line 126: <%=Html.MvcSiteMap().SiteMapPath(" &gt; ") %>
Line 127: <div class="clear">
Line 128: </div>


Source File: c:\inetpub\wwwroot\UDAF\branches\UDAF\Views\Shared\Site.Master    Line: 126

Stack Trace:

[ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.]
System.Reflection.Module._GetTypesInternal(StackCrawlMark& stackMark) +0
System.Reflection.Assembly.GetTypes() +105
MvcSiteMapProvider.<>c__DisplayClass18.<GetControllerTypeWithinNamespaces>b__c(Assembly a) in C:\Projects\TFS10.CODEPLEX.COM\mvcsitemap\Main\MvcSiteMapProvider\MvcSiteMapProvider\DefaultControllerTypeResolver.cs:157
System.Linq.WhereSelectArrayIterator`2.MoveNext() +61
System.Linq.<SelectManyIterator>d__31`3.MoveNext() +130
MvcSiteMapProvider.DefaultControllerTypeResolver.GetControllerTypeWithinNamespaces(String area, String controller, HashSet`1 namespaces) in C:\Projects\TFS10.CODEPLEX.COM\mvcsitemap\Main\MvcSiteMapProvider\MvcSiteMapProvider\DefaultControllerTypeResolver.cs:166
MvcSiteMapProvider.DefaultControllerTypeResolver.ResolveControllerType(String areaName, String controllerName) in C:\Projects\TFS10.CODEPLEX.COM\mvcsitemap\Main\MvcSiteMapProvider\MvcSiteMapProvider\DefaultControllerTypeResolver.cs:69
MvcSiteMapProvider.DefaultActionMethodParameterResolver.ResolveActionMethodParameters(IControllerTypeResolver controllerTypeResolver, String areaName, String controllerName, String actionMethodName) in C:\Projects\TFS10.CODEPLEX.COM\mvcsitemap\Main\MvcSiteMapProvider\MvcSiteMapProvider\DefaultActionMethodParameterResolver.cs:58
MvcSiteMapProvider.DefaultSiteMapProvider.NodeMatchesRoute(MvcSiteMapNode mvcNode, IDictionary`2 values) in C:\Projects\TFS10.CODEPLEX.COM\mvcsitemap\Main\MvcSiteMapProvider\MvcSiteMapProvider\DefaultSiteMapProvider.cs:687
MvcSiteMapProvider.DefaultSiteMapProvider.FindControllerActionNode(SiteMapNode rootNode, IDictionary`2 values) in C:\Projects\TFS10.CODEPLEX.COM\mvcsitemap\Main\MvcSiteMapProvider\MvcSiteMapProvider\DefaultSiteMapProvider.cs:650
MvcSiteMapProvider.DefaultSiteMapProvider.FindSiteMapNode(HttpContext context) in C:\Projects\TFS10.CODEPLEX.COM\mvcsitemap\Main\MvcSiteMapProvider\MvcSiteMapProvider\DefaultSiteMapProvider.cs:609
System.Web.SiteMapProvider.get_CurrentNode() +35
System.Web.SiteMap.get_CurrentNode() +34
MvcSiteMapProvider.Web.Html.SiteMapPathHelper.SiteMapPath(MvcSiteMapHtmlHelper helper, String separator, String separatorCssClass, String linkCssClass, Boolean currentNodeAsLink, Object htmlAttributes) in C:\Projects\TFS10.CODEPLEX.COM\mvcsitemap\Main\MvcSiteMapProvider\MvcSiteMapProvider\Web\Html\SiteMapPathHelper.cs:91
MvcSiteMapProvider.Web.Html.SiteMapPathHelper.SiteMapPath(MvcSiteMapHtmlHelper helper, String separator) in C:\Projects\TFS10.CODEPLEX.COM\mvcsitemap\Main\MvcSiteMapProvider\MvcSiteMapProvider\Web\Html\SiteMapPathHelper.cs:35
ASP.views_shared_site_master.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in c:\inetpub\wwwroot\UDAF\branches\UDAF\Views\Shared\Site.Master:126
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +256
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Control.Render(HtmlTextWriter writer) +10
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +134
System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +19
System.Web.UI.Page.Render(HtmlTextWriter writer) +29
System.Web.Mvc.ViewPage.Render(HtmlTextWriter writer) +59
System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +27
System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +99
System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +25
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1266

Coordinator
Jun 22, 2010 at 10:19 AM

Did you register the extensions in web.config? i.e.:

  <system.web>
    <pages>
      <namespaces>
        <!-- -->
        <add namespace="MvcSiteMapProvider.Web.Html" />
      </namespaces>
    </pages>
  </system.web>
Jun 22, 2010 at 3:54 PM
Edited Jun 22, 2010 at 5:24 PM

yes I do have that in there. 

I just put the source code from your lastest build in and this is a little more descriptive of an error.

 

Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

Source Error:


Line 155:                // Find possible assemblies
Line 156:                var possibleAssemblies = AppDomain.CurrentDomain.GetAssemblies()
Line 157:                    .Where(a => a.GetTypes().Where(t => t.Name != null && t.Name == controller + "Controller").Count() > 0);
Line 158:
Line 159:                // Find types
 

Source File: C:\inetpub\wwwroot\UDAF\branches\MvcSiteMapProvider\DefaultControllerTypeResolver.cs    Line: 157

Jun 22, 2010 at 8:01 PM
Edited Jun 22, 2010 at 8:02 PM

so far this is my fix..

 

var possibleAssemblies = AppDomain.CurrentDomain.GetAssemblies().Where(x=> !x.FullName.Contains("Castle"))
                    .Where(a => a.GetTypes().Where(t => t.Name != null && t.Name == controller + "Controller").Count() > 0);

 

is there a more elegant way to accomplish this?

Coordinator
Jun 23, 2010 at 2:46 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.