I'm trying to write a custom navigation provider for SharePoint 2010. Later it should be able to distinguish between two different web templates so that sites with one template are only shown in the current navigation on the left and that other sites with another web template are only shown in the top navigation bar. For this purpose I created a very simple navprovider following this tutorial:

My class:

    using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.SharePoint.Publishing;
using Microsoft.SharePoint.Publishing.Navigation;
using System.Web;
using System.Web.UI.WebControls;
using System.Configuration;

namespace xyz.SharePoint
public class PortalNavProvider: PortalSiteMapProvider
    public override SiteMapNodeCollection GetChildNodes(System.Web.SiteMapNode node)
        PortalSiteMapNode pNode = node as PortalSiteMapNode;
        if (pNode != null)
            if (pNode.Type == NodeTypes.Area)
                SiteMapNodeCollection nodeColl = base.GetChildNodes(pNode);
                SiteMapNode childNode = new SiteMapNode(this, "<http://www.microsoft.com>", "<http://www.microsoft.com>", "Microsoft");

                SiteMapNode childNode1 = new SiteMapNode(this, "<http://support.microsoft.com>", "<http://support.microsoft.com>", "Support");


                SiteMapNodeCollection test = new SiteMapNodeCollection();
                childNode.ChildNodes = test;

                return nodeColl;
                return base.GetChildNodes(pNode);
            return new SiteMapNodeCollection();


It doesn't do anything else than the tutorial so far, because I simply wanted to test this thing at first. Then I copied the dll to \inetpub\wwwroot\wss\VirtualDirectories[Web-App-Name_app_bin (I also tried \14\BIN but didn't change anything) and edited the web.config and added:

    <siteMap defaultProvider="CurrentNavigation" enabled="true">
    <add name="MyCustomNavigationProvider" type="xyz.SharePoint.PortalNavProvider, xyz.SharePoint, Version=, Culture=neutral, PublicKeyToken=07c8018bfe42d33f" NavigationType="Global" />
</siteMap><trust level="Full" originUrl="" />

The custom navigation provider should be included in a custom masterpage - not in the v4.master. Because of that I added the provided section to the mustom masterpage:

                            <StaticMenuItemStyle CssClass="ms-topnav" ItemSpacing="0px"/>
                            <StaticSelectedStyle CssClass="ms-topnavselected" />
                            <StaticHoverStyle CssClass="ms-topNavHover" />
                            <DynamicMenuStyle BackColor="#F2F3F4" BorderColor="#A7B4CE" 
                            <DynamicMenuItemStyle CssClass="ms-topNavFlyOuts"/>
                            <DynamicHoverStyle CssClass="ms-topNavFlyOutsHover"/>
                            <DynamicSelectedStyle CssClass="ms-topNavFlyOutsSelected"/>

I tried that via Site Actions -> edit with SharePoint Designer and opened the masterpage, but that didn't work. So I tried to edit the masterpage in the solution it belongs to and deployed it again. At the moment I get the following error if I try to open the site:
The DataSourceID of 'TopNavigationMenuV4' must be the ID of a control of type IHierarchicalDataSource. A control with ID 'topSiteMap' could not be found.

Several things are confusing me at this point. After deploying everything new the site usually uses the standard masterpages at first and I have to change that to the custom masterpage. So why does the site throw that error if the changes are in the custom masterpage?
Besides, in the custom masterpage there is this part:

    <SharePoint:AspMenu ID="TopNavigationMenuV4" runat="server" EnableViewState="false"
                            DataSourceID="topSiteMap" AccessKey="<%$Resources:wss,navigation_accesskey%>"
                            UseSimpleRendering="true" UseSeparateCSS="false" Orientation="Horizontal" StaticDisplayLevels="2"
                            MaximumDynamicDisplayLevels="1" SkipLinkText="" CssClass="s4-tn" />
                        <SharePoint:DelegateControl runat="server" ControlId="TopNavigationDataSource" ID="topNavigationDelegate">
                                <asp:SiteMapDataSource ShowStartingNode="False" SiteMapProvider="SPNavigationProvider"
                                    ID="topSiteMap" runat="server" StartingNodeUrl="sid:1002" />

So the SiteMapDataSource "topSiteMap" IS there and worked before I added my nav provider. I thought okay maybe there shouldn't be two of them and put the part shown above into a comment. Didn't change anything either.
Does anyone have an idea where the problem could be?

I found something else in the ULS logs. Besides the error message, I already posted, there is this one:

    DelegateControl: Exception thrown while adding control     'Microsoft.SharePoint.Publishing.Navigation.PortalSiteMapDataSourceSwitch': Could not load type 'xyz.SharePoint.PortalNavProvider' from assembly 'xyz.SharePoint, Version=, Culture=neutral, PublicKeyToken=07c8018bfe42d33f'. (C:\inetpub\wwwroot\wss\VirtualDirectories\Web App-80\web.config line 434)

Edit 2:

Okay now I'm completely confused. I used the back button and now the site loads, with the custom masterpage applied. But when I click on site actions -> site settings, I get an empty site

But even when the site loads, when I click the back button of the browser, the same errors appear in the ULS log.

Edit 3:
Somehow I "resolved" the error mentioned above, though I'm not quite sure. Now I'm getting another error and I hope that someone can help me at least with this one.
But first to the previous error: I think it occured, because I was editing the web.config manually and did something wrong. I read that simply one character at the wrong place in the web.config could cause this error. So I removed my changes and put them back in, but carefully. And indeed, the error was gone.
But that is the surpirse I got... a new error of course:

System.TypeLoadException: Could not load type 'xyz.SharePoint.PortalNavProvider' from assembly 'xyz.SharePoint, Version=, Culture=neutral, PublicKeyToken=07c8018bfe42d33f'.   
 at System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, Boolean loadTypeFromPartialName)    
 at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)    
 at System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark)    
 at System.Type.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)    
 at System.Web.Compilation.BuildManager.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase)    
 at System.Web.Configuration.ConfigUtil.GetType(String typeName, String propertyName, ConfigurationElement configElement, XmlNode node, Boolean checkAptcaBit, Boolean ignoreCase)

But still... I have no idea how to handle this one

  • Added a new error message from ULS log.
    – Jess
    Commented May 22, 2013 at 13:17
  • And another addition...
    – Jess
    Commented May 24, 2013 at 11:23

2 Answers 2


I've had the same issue for several reasons. Maybe you could try one or more of these:

  • Recycle the relevant application pool(s) in IIS. They tend to cache old dlls and this might cause an issue.

  • Check that the dll in the GAC (c:\windows\assembly) is indeed the latest version of your dll. Sometimes it may be locked by other processes and thus cannot be updated when you deploy from Visual Studio. One thing you could do is delete it manually from the GAC and deploy it again (remember to recycle the application pool and relevant services when you do this).

  • Recycle all relevant SharePoint processes so they do not contain old versions of your dll. Start -> Run "services.msc" (or just type "services" and pick it from the list). Depending on what you need you might want to recycle these: SharePoint 2010 Administration, SharePoint 2010 Timer, SharePoint 2010 User Code Host.


Your new error is typical for when your solution is not installed (the .dll is not present in the GAC)

  • It has to appear in C:\Windows\assembly or did I get something wrong maybe? Because it actually is there
    – Jess
    Commented May 24, 2013 at 12:34
  • Is this for 2013 or 2010? For 2013 it should be deployed to C:\Windows\Microsoft.NET\assembly\GAC_MSIL Commented May 24, 2013 at 12:36
  • SharePoint 2010 - sorry forgot to mention it, but I'll edit it in the main post
    – Jess
    Commented May 24, 2013 at 12:37
  • Well the compiler is not able to find your class in the assembly present in the GAC for some reason, could be some error in the package file for your project Commented May 24, 2013 at 12:39
  • stackoverflow.com/questions/5735673/… Commented May 24, 2013 at 12:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.