Disabling ValidationExceptions when debugging Silverlight applications

The Problem: After annotating a model with data annotation attributes, Visual Studio halts program execution when the Silverlight application fails on the ValidationException. Continuing execution will display the error on the Silverlight dataform as expected. What you really want is for Visual Studio to ignore the ValidationException and just display the error message on the Silverlight form.

The Fix: Tell Visual Studio to ignore ValidationExceptions. Press cntrl-alt-E to open the Exceptions dialog. Click the Add button and select “Common Language Runtime Exceptions” From the Type dropdown. Enter “System.ComponentModel.DataAnnotations.ValidationException” into the Name box and press ok. Find the line you just added in the Exceptions list and clear the User-unhandled checkbox. Now your exceptions will appear in your app as expected! Happy coding!

 

VisualStudioExceptionsDialog

The name ‘InitializeComponent’ does not exist in the current context

I get this error in my Silverlight projects occasionally and even though my projects still compile this error is annoying. I found a quick fix on the Silverlight forums which worked for me. Click on the xaml file causing the error and change the “Custom Tool” setting from MSBuild:MarkupCompilePass1 to MSBuild:CompileXaml and rebuild. The error should no longer appear. Remember to set the custom tool back to MSBuild:MarkupCompilePass1.

Book Review – Foundation Expression Blend 3 with Silverlight

 

I have worked my way though most of this book and I have found it very helpful in getting started with Blend. In Foundation Expression Blend 3 with Silverlight, Victor Guidioso has assembled an excellent collection of examples that walk you through creating Silverlight applications from scratch using a combination of Blend and Visual Studio. This book is written in a style that emphasizes jumping right in and getting the job done. There are no gratuitous “video in a button” type examples here but examples based on the types of projects you are most likely to write. I found an error in the book which had a bad link for a source code download URL so I sent an email. To my surprise, not only did I get a reply email notifying me the link was fixed, Victor called me to let me know. You can’t ask for anything better than that! Anyway, I found this book extremely helpful in getting started writing Silverlight applications with Blend and I think you will too!