Ok this was just too weird to leaving without blogging. I’m playing with an open source project at the moment and while navigating around the solution in Visual Studio I kept getting errors when I tried to open various forms in the various projects (some forms worked, some didn’t). Here’s what the error looks like in the Visual Studio forms designer:

Ugly. The form in question is AboutForm.cs and I figured that the problem had to be in the AboutForm.Designer.cs as this is usually the cause of this error, i.e. something in there can’t be parsed or understood by the VS forms designer so it just packs up and goes out to lunch.
I added a new form to the application and, piece by piece, added the source from the offending form to the new form until it broke … and break it did. The forms designer started having problems with the declarations and instances of the application’s custom controls; removing them allowed the form to load without a problem. Having a look at the custom control’s source didn’t show anything so I tried to drag an instance of the control I knew was causing the issue into my new form. Disaster! An ugly System.Xml.XmlException was thrown at me – here’s what it looks like:

Just like the first one – ugly! Ok so at least I knew what the base cause of the problem was, unlike the unhelpful error the forms designer gave me earlier. Some research turned up some seemingly unrelated posts that indicated other people had received this error but in different circumstances. A pattern emerged though; an ampersand (&) character appeared in the name of the folder the solution was stored in (my solution was in C:\Data\Solutions\reference & libraries).
The fix? Close the solution, close all instances of Visual Studio, rename the folder to “reference and libraries”, restart Visual Studio and reload the solution.
That’s a candidate for “The Daily WTF” to me …