Visual Studio 2010, WPF Designer throws NullReferenceException - by thesnoman

Status : 

  By Design<br /><br />
		The product team believes this item works according to its intended design.<br /><br />
		A more detailed explanation for the resolution of this particular item may have been provided in the comments section.

Sign in
to vote
ID 534927 Comments
Status Closed Workarounds
Type Bug Repros 0
Opened 2/19/2010 12:32:14 PM
Access Restriction Public


For some reason, with VS 2010 and .Net 4, when I try to open some of my windows in the WPF designer I get a NullReferenceException.  When I review the code causing the problem it refers to some AddHandler calls I have in the form's Loaded event procedure.  I know the events they are refering to are in other files not loaded until you actually run the program, which by the way runs fine.  This same code ran fine in VS 2008 and .Net 3.5.  I'm thinking this must be a bug.  Why is the designer trying to run this code anyway?
Sign in to post a comment.
Posted by tnetland on 2/26/2012 at 6:24 AM
There is a sample family tree WPF application written by someone at Microsoft in VS 2008 called When I download the software and convert it to VS 2010, the form MainWindow.XAML produces this result. In VS 2008, this problem does not occur. The source can be found at the following link:
Posted by Microsoft on 2/22/2010 at 2:49 PM
Thank you for your feedback. Yes, you have identified the correct workaround for this situation -- to use DesignerProperties.GetIsInDesignMode to make sure runtime specific sections of code are not executed at design-time.

Feel free to contact me if you have any further questions. You can reach me at: ramatthi (at) microsoft (dot) com.
Posted by Microsoft on 2/22/2010 at 12:51 AM
Thanks for reporting this issue. In order to fix the issue, we must first reproduce the issue in our labs. We are unable to reproduce the issue with the steps you provided.

Please give us a demo project to demonstrate this issue so that we can conduct further research.

It would be greatly appreciated if you could provide us with that information as quickly as possible. If we do not hear back from you within 3 days, we will close this issue.

Thanks again for your efforts and we look forward to hearing from you.

Visual Studio Product Team
Posted by Microsoft on 2/20/2010 at 7:05 PM
Thank you for your feedback, we are currently reviewing the issue you have submitted. If this issue is urgent, please contact support directly(