Refreshing SiteMap structure

Topics: Web Client Software Factory
Jul 3, 2007 at 3:34 PM
Hello, I am having a problem when trying to refresh my SiteMap. The thing is that I get my structure from a database, and what I need is to say the Composite app block to reload the SiteMap.

I was looking into the code and saw that it only loads and configures the modules in the Application_Start.
So this is done only once. I taught of making a function that would execute only the needed functions to reload the SiteMap, but I can't figure how to do it exactly since I don't find any explicit instances of Microsoft.Practices.CompositeWeb.WebClientApplication in my application.

Basically my questions is, what whould be the correct method to do this?
Jul 3, 2007 at 6:38 PM
This is another problem I have trying to figure this out:

I opened the source of the Composite Application Block compiled it and replaced the dll's in my wcsf solution with those ones (whitout making any changes in the source yet).

This is the error I got:

Server Error in '/DevelopmentWebsite' Application.

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:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

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() +86
Microsoft.Practices.CompositeWeb.Services.ModuleLoaderService.Load(ICompositionContainer compositionContainer, IModuleInfo[] modules) +636
Microsoft.Practices.CompositeWeb.WebClientApplication.LoadModules() +221
Microsoft.Practices.CompositeWeb.WebClientApplication.Application_Start(Object sender, EventArgs e) +148
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.210

The idea is changing the source code, but I get this error without even doing it, so I wondered if the dll's provided with wcsf are the same as the generated by the wcsf source code.

Maybe I'm missing something or doing something wrong?

How am I supposed to work with the SiteMapBuilderService and a dynamic SiteMap structure if the SiteMapBuilderService only allows to Add nodes and get childs of one parent?

What I need to do is just restart the loading process so it gets the data from the db and refreshes it (not sure if it is the right way to solve this?).

Thanks again...
Jul 4, 2007 at 6:18 PM

I received your email message.

You will probably need to create your own SiteMapBuilderService that implements ISiteMapBuilderService that reads the information from a database as needed.

Then in the ShellModuleInitializer you can replace the current SiteMapBuilderService with your own:

        protected virtual void AddGlobalServices(IServiceCollection globalServices)
            globalServices.AddNew<EnterpriseLibraryAuthorizationService, IAuthorizationService>();
            // Remove this and add your own...
            _siteMapBuilderService = globalServices.AddNew<SiteMapBuilderService, ISiteMapBuilderService>();

You could also just use a different SiteMapProvider as well. The default is shown in the web.config and part of the CWAB:

    <siteMap defaultProvider="DefaultSiteMapProvider" enabled="true">
        <add name="DefaultSiteMapProvider" type="Microsoft.Practices.CompositeWeb.Providers.ModuleSiteMapProvider, Microsoft.Practices.CompositeWeb" securityTrimmingEnabled="true"/>

But, nothing says you need to use the one provided by the WCSF. You could use the ones provided in ASP.NET 2.0 or other custom ones I have seen floating around in the past.




David Hayden
Microsoft MVP C#
Jul 4, 2007 at 7:51 PM

As David says in the previous post you could just extend the SiteMapBuilderService, adding the functionality you want. This is the better way to do it as you don’t have to change the assemblies.

In case you still wanted to do the recompilation, the steps needed to use your own CompositeWeb dlls would be:

  1. Open the CompositeWeb solution, modify it and build the solution.
  2. Take the following assemblies from WCSF Source\Blocks\CompositeWeb\Source\CompositeWeb.EnterpriseLibrary\bin\Debug:
    • Microsoft.Practices.CompositeWeb
    • Microsoft.Practices.CompositeWeb.EnterpriseLibrary
    • Microsoft.Practices.ObjectBuilder.WCSFExtensions
  1. Copy them to your solution’s library folder.
  2. Rebuild your solution.

You are having that error because some of the assemblies were compiled using the signed version of the Microsoft.Practices.CompositeWeb assembly. In the moment you replace that assembly, the others couldn’t find this dependency because your compiled assembly is not signed anymore . That’s why you also have to replace the Microsoft.Practices.CompositeWeb.EnterpriseLibrary and the Microsoft.Practices.ObjectBuilder.WCSFExtensions assemblies.

Maybe there’s a chance that refreshing may be done programmatically (getting the new nodes from your db and appending them into your sitemap, via the SiteMapBuilderService and SiteMapNodeLocator services). Take a look at this thread (, you might find it useful.

Hope it helps!

Luciano G. Panaro