This blog has, IMO, some great resources. Unfortunately, some of those resources are becoming less relevant. I'm still blogging, learning tech and helping others...please find me at my new home on

Wednesday, May 27, 2009

VS.Net Crashes When Editing Xaml Resource File

I have found what I believe to be a bug in Visual Studio 2008 when editing a Xaml Resource file.

Visual Studio 2008 stops responding if you edit an in-use style to be something invalid.  Now, you may be thinking, “Why on Earth would you want your style to be invalid?” …and that’s not really where I’m going with this.

Below is a visual to get where I’m at.  Just, please, brace yourself before you set eyes on this image; I used up the remainder of my annual illustration budget to enhance and superimpose qualifiers to properly indicate the exact cause of the problem.  For inexperienced graphic observers, the following image may just cause your retinas to implode with visual excitement:


Pretty crazy graphics, eh?

Well, you’re still reading so your eyes must still be in tact.  Here’s what I was doing:

  1. Created a button style for use in a user control
  2. Moved the style into a resource file
  3. Applied the style to my button
  4. Wanted to change the margin as well, so I copied and pasted the ‘BorderThickness’ line. The only thing I like less that copy-and-pasting is typing…
  5. Visual Studio implodes (as your eyes may have from the previous illustration.

I’m assuming that the problem is that, internally, an exception is being kicked up somewhere because either the style can’t render (other invalid states cause Visual Studio to puke, too, like incomplete Xaml tags in the style), or because of a problem like I’ve illustrated with a property being set multiple times.

I did a little more digging and found that Visual Studio only stops responding if you have a designer open that uses the style.  In other words, if I close all the designers that have a button using the style in question, I am able to successfully copy and paste invalid code into the style.

The good news is that the work-around is easy: close all your designers before editing in-use styles.  The bad news is that, if you’re like me, you’re working in multiple designers at once and re-using styles.

I have five MVVM views implements as UserControls that compose my main UI (each spawning other views) so when you’re trying to pull everything together this can be a pain in the arse.

UPDATE: I did find this KB article that will allow for a hotfix download for qualified parties…calling in now for download instructions…

No comments:

Post a Comment