Visual Studio soft-crashing when encountering XAML Errors in initialize.

Posted by Aren on Stack Overflow See other posts from Stack Overflow or by Aren
Published on 2011-01-04T17:43:25Z Indexed on 2011/01/06 17:53 UTC
Read the original article Hit count: 342

Filed under:
|
|
|

I've been having some serious issues with Visual Studio 2010 as of late. It's been crashing in a peculiar way when I encounter certain types of XAML errors during the InitializeComponent() of a control/window.

The program breaks and visual studio gears up like it's catching an exception (because it is) and then stops midway displaying a broken highlight in my XAML file with no details as to what is wrong. Example:

alt text

There is not pop outs, or details Anywhere about what is wrong, only a callstack that points to my InitializeComponent() call.

Now normally I'd just do some trial and error to fix this problem, and find out where i messed up, but the real problem isn't my code. Visual Studio is rendered completely useless at this point. It reports my application still in "Running" mode. The Stop/Break/Restart buttons on the toolbar or in the menus don't do anything (but grey out).

Closing the application does not stop this behaviour, closing visual studio gets it stuck in a massive loop where it yells at me complaining every file open is not in the debug project, then repeats this process when i have exausted every open file.

I have to force-close devenv.exe, and after this happening 3-4 times in a row it's a lot of wasted time (as my projects are usually pretty big and studio can be quite slow @ loading).

To the point

  1. Has anyone else experienced this?
  2. How can I stop studio from locking up.
  3. Can I at LEAST get information out of this beast another way so i can fix my XAML error sooner rather than after 3-4 trial-and-error compiles yielding the same crash?

Any & All help would be appreciated.

Visual Studio 2010 version: 10.0.30319.1RTM

Edit & Update

FWIW, mostly the errors that cause this are XamlParseExceptions (I figured this out after i found what was wrong with my XAML).

I think I need to be clearer though, Im not looking for the solution to my code problem, as these are usually typos / small things, I'm looking for a solution to VStudio getting all buggered up as a result.

The particular error in the above image that 100% for sure caused this was a XamlParseException caused by forgetting a Value attribute on a data trigger.

I've fixed that part but it still doesn't tell my why my studio becomes a lump of neutered program when a perfectly normal exception is thrown in the parsing of the XAML.

Code that will cause this issue (at least for me)

This is the base template WPF Application, with the following Window.xaml code. The problem is a missing Value="True" on the <DataTrigger ...> in the template. It generates a XamlParseException and Visual Studio Crashes as described above when debugging it.

Final Notes

The following solutions did not help me:

  1. Restarting Visual Studio
  2. Rebooting
  3. Reinstalling Visual Studio

© Stack Overflow or respective owner

Related posts about .NET

Related posts about wpf