Exception using Sitemap class

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I am writing a custom control (code see below) and I am getting an
exception that drives me crazy.

When I drag my control on a form, Visual Studio shows immediately the
following exception:

"Error Rendering Control - NiftyMenu1 An unhandled exception has
occurred. The provider 'AspNetXmlSiteMapProvider' specified for the
defaultProvider does not exist in the providers collection."

What does that mean exactly? For debugging purpoes I list my providers
with the following code:



<%@ Page Language="C#" %>
"-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>

<SCRIPT runat="server"&gt;
private void Page_Load(object sender, System.EventArgs e)
{

IEnumerator providers = SiteMap.Providers.GetEnumerator();
while (providers.MoveNext())
{
Response.Write(providers.Current);
}
}



I am getting the output: System.Web.XmlSiteMapProvider

So I think it should find it. Or is it System.Web.XmlSiteMapProvider
different to AspNetXmlSiteMapProvider?

What am I missing? Must be something obvious but I can't see it.

Any help is very much appreciated.







Here is the code of my control:



1 using System;
2 using System.Collections.Generic;
3 using System.ComponentModel;
4 using System.Text;
5 using System.Web;
6 using System.Web.UI;
7 using System.Web.UI.WebControls;
8
9 namespace MyControls
10 {
11 [ToolboxData("&lt;{0}:NiftyMenu
runat=server></{0}:NiftyMenu>")]
12 public class NiftyMenu : WebControl
13 {
14 protected override void RenderContents(HtmlTextWriter
output)
15 {
16 RenderMasterMenu(output);
17 }
18
19 protected virtual void RenderMasterMenu(HtmlTextWriter
output)
20 {
21 output.Write("&lt;ul id=\"nav\"&gt;");
22 // The following line produces the exception
23 SiteMapNode node = SiteMap.CurrentNode;
24 }
25 }
26 }

The offending line is #23. If I comment that out the exception is
gone. But I need the SiteMap class!

.



Relevant Pages

  • Exception using sitemap class
    ... exception that drives me crazy. ... When I drag my control on a form, ... For debugging purpoes I list my providers ... 12 public class NiftyMenu: WebControl ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Multithreaded GUI issues
    ... The code is happening in a try/catch handler, but the exception is taking place in a callback thread that I have no control over. ... were actually trying to close a socket at the time the exception occurred, so you might want to check to see why something is trying to close a socket when you don't expect to. ... But how do I know that creating an Image object is thread safe? ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: What does it mean?
    ... > But, if you would like to save yourself all of the exception processing, a ... (That's what a cast does internally.) ... > control array is a particular control. ... >> where the result isn't a TextBox, ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: GUI Thread - Is cross-thread operation really bad?
    ... Yes, it will throw exception when running inside IDE/debugger, but if I ... to WPF which always throws exception. ... control via window messages). ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Deleting Problem
    ... TestBox control for the description and a hidden control for the ID. ... An unhandled exception occurred during the execution of the ... be identified using the exception stack trace below. ... The delete query i am using is as follows: ...
    (microsoft.public.dotnet.framework.aspnet)