Richard Fleming

All MindsharpBlogs

Binary Ramblings

My Links

Post Categories

Archives

Blog Stats

Error in XML Document (1,40)

Error messages tend, by default, not to be overly helpful. Sometimes though, they're just plain baffling. This is the case for the Error in XML Document error. I received this error when trying to add my current project to a fresh portal. Every time I went to Add Web Parts and dragged/dropped the part into a zone, the Error in XML Document (1,40) message would appear in the side menu in red letters.

Well, after much digging, I have figured out why it does this. It is caused by an unhandled exception in a constructor. I had missed a few spots in my code when I went back and refactored my error handling, and so the web part didn’t gracefully handle empty tables. Fixed the problem (and added a general try/catch to my constructor) and I was able to add the web part back in. 

To test: Create a new web part, verify it is safe and working, then add the following:

public YourClassName(){
   throw new Exception();
}
 

C#

VB

Rebuild/deploy. The web part that was already added in will display a ‘Cannot desieralize’ error message. If you try to add it in again, you will get the XML Document error. To fix change the constructor to this:

public YourClassName(){
   try
   {
      throw new Exception();
   }
   catch { }
}
 

C#

VB

Rebuid/deploy. Error will be fixed.

posted on Tuesday, March 15, 2005 8:44 AM

Feedback

# re: Error in XML Document (1,40) 8/13/2006 12:22 AM Conner

it dosent work on myspae music

# re: Error in XML Document (1,40) 6/20/2008 10:27 AM bedava oyunlar

You sholud use second method fir your errror

Title  
Name  
Url
CAPTCHA
Protected by Clearscreen.SharpHIPEnter the code you see:
Comments