WPF Designer "Could not create an instance of type" WPF Designer "Could not create an instance of type" wpf wpf

WPF Designer "Could not create an instance of type"


The problem was that the base class was defined as abstract. This caused the designer to fail. This problem is described in more detail in the comments section of Laurent Bugnion's blog: http://geekswithblogs.net/lbugnion/archive/2007/03/02/107747.aspx


I found a very useful solution to this on :http://www.progware.org/Blog/post/WPF-Designer-Error-Could-not-create-an-instance-of-type.aspx.

This link explains how the WPF designer window runs the Constructor to display the UI in XAML and the remedy:adding the following snippet to any part of constructor code which might be giving error:

if(!System.ComponentModel.DesignerProperties.GetIsInDesignMode(this)){   //code producing exception         }

the function name is self explanatory. :) This link also provides solutions on debugging issues with XAML.


Another possible cause, as we just found here, so I'm adding this answer for future users, is if the project is hosted on an untrusted source, such as a file server.

In that case, the designer wouldn't load the assembly and so gave the same "Could not create instance..." error. The solution would still build and debug OK.