Welcome to Pete Brown's 10rem.net

First time here? If you are a developer or are interested in Microsoft tools and technology, please consider subscribing to the latest posts.

You may also be interested in my blog archives, the articles section, or some of my lab projects such as the C64 emulator written in Silverlight.

(hide this)

Silverlight RC0 Debugging Tip – Check your VSM Styles

Pete Brown - 26 September 2008

 

This tip is somewhat buried at the end of my RC0 introductory post. However, I can’t emphasis enough that the main reason you get initialization errors or the WSOD (White Screen of Death) in Silverlight 2 is problems in your visual states.

There are a few approaches and steps to debugging this.

  1. Open your project in Blend and look at the xaml files (start with app.xaml if that’s where most of your styles are located). Let Blend parse it and report errors. Fix what it finds and then run your app. Blend will catch many things Visual Studio will not.
  2. If that doesn’t remove the error, comment out the guts of your styles (not the outermost style tags) one by one, running each time. Yes, this is like how we used to have to debug undebuggable stuff like early ASP, but it is a tried and true approach. If you run after each time, you’ll be able to see which one was making your app bomb. Fix or recreate the offending style or get more granular with your commenting-out.
  3. If that doesn’t work, save a copy of your project and then remove all the “vsm:” prefixes from your styles. This isn’t step #1 because there may be cases where the “vsm:” prefix is required, and it will be next to impossible for you to find them after the fact. Just remember to back up the files before you do this. This problem usually manifests itself at design time

These are all artifacts of developing on beta software and then porting to a release. As an early adopter, this is not unexpected. Microsoft has given everyone a big old heads up by releasing the developer-only RC0, so I encourage you to use this time to get your apps ready for RTW.

If you run across any issues, please ping me here, or if you want a quicker response, post the questions on the forums over at silverlight.net

[Update: As I mention in the comments below, keep the vsm: in all the Visual* tags, and remove it from the other ones which are not vsm-specific. This makes perfect sense as the vsm: namespace prefix only needs to scope the items that are vsm-specific]

   
posted by Pete Brown on Friday, September 26, 2008
filed under:    

8 comments for “Silverlight RC0 Debugging Tip – Check your VSM Styles”

  1. Pete Brownsays:
    Ok, latest recommendation (and this makes sense) is to remove the vsm: prefix from all style and setter tags, but keep it for all VisualState* tags (like VisualStateManager and VisualStateGroup), as those are actually in the vsm namespace.

    Pete
  2. Young Ohsays:
    Many thank Pete !!!
    After(not before unfortunately) wasting so many hours, I came to your advice and applied it.
    Bingo. It worked.
    Then I reconstructed the error to see where the error exactly was.
    As you said, vsm:Visual....were all ok.
    Also vsm:Style and vsm:Setter were ok as well.
    But <vsm:Setter.Value> was causing the problem with the following error message in my case.
    title: "XamlParseException occured"
    AG_E_PARSER_PROPERTY_NOT_FOUND [Line:99 Position:99].
    So changing <vsm:Setter.Value> to <vsm:Setter> fixed the problem. Again thanks a lot.
  3. Eric Willekesays:
    #2 did it for me. Specifically, I removed the vsm: from from the Style and Setter tags, which cleaned up something very nicely.

    Oddly enough, #1 gave me a false negative, where it was telling me I couldn't put a Grid as the child of a Border. Oh well, never can tell ;)
  4. Eric Willekesays:
    I'm not seeing this in the breaking changes list, but it seems the runtime is being much more aggressive in how it enforces duplicate x:Name usage. Before, it was essentially on a per-UserControl basis, as I could have (for example) an x:Name="CloseButton" in my root page, and other one in a user control that was loaded from that page. Now, it gives me "The name already exists in the tree: CloseButton"
  5. Eric Willekesays:
    I've not dug into it yet, but I've also seen an issue with changes to Layout and/or Measure throwing exceptions where they weren't before. It doesn't appear to be the infinite loop exception that is mentioned, but it could be related. Don't suppose anybody's seen a PagingStackPanel out there?

Comment on this Post

Remember me

3 trackbacks for “Silverlight RC0 Debugging Tip – Check your VSM Styles”

  1. Community Blogssays:
    Jeff Handley on Layout Cycle and ContentPresenter gotchas, Pete Brown on VSM Styles and SL2 RTM, Bill
  2. Community Blogssays:
    By now, you probably heard that Silverlight 2 RC0 is out and available for download . While you’ll
  3. POKE 53280,0: Pete Brown's Blogsays:
    This is the second birth I’ve been privileged to witness this month, and if I made any more comparison