WPF, 'Object reference not set to an instance of an object' in Designer WPF, 'Object reference not set to an instance of an object' in Designer wpf wpf

WPF, 'Object reference not set to an instance of an object' in Designer


What Alex says is the way to go. But I think its a little confusing to understand what he is saying.

Assuming you have your project open in Visual Studio, open another Visual Studio instance and select Debug->Attach To Process. In the dialog which opens select

  • XDesProc.exe (which is the XAML UI Designer) for VS2012 and newer or
  • devenv.exe for older VS versions.

Then do "Reload Designer" for the user control and see the output in the second VS instance to check what exactly is the error.


If you have 'Object reference not set to an instance of an object' in XAML, but your application compiles and runs fine, you will usually find out that its cause is something in a constructor that can't be resolved at design time.

While you can find out the root of the problem with the help of other answers to this question, sometimes that is something you can't simply fix, you need it in your code exactly as you have it, but you don't want to see this error.

In this case, just click the "Disable project code" button located on the bottom of your designer view and Visual Studio designer will stop trying to construct an instance to provide design time data view.

See here for detailed information.

enter image description here


It's probably something in the constructor of your user controls. VS2008 WPF designer appears have some issues with this.

In a project we took over, we added:

if (System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)){    return;}

to the beginning of the constructor of the user controls where this happens to avoid that error.