views:

81

answers:

2

Environment

  • Visual Studio 2008 SP1
  • Visual C#
  • WPF Application Project
  • .NET Framework 3.5

Problem

You have a user control in the same assembly as another user control or window, and you are using it in this new user control or window. It compiles and runs fine, however the designer doesn't work and gives an exception "Could not create an instance of type 'x'.". This prevents the designer from rendering and the project from compiling while the designer is visible.

Workaround

While by hiding the designer on these controls and windows it allows the code to compile this is not an expectable solution as it prevents me from viewing and using the designer completely for these controls and windows.

Code Examples

xmlns:local="clr-namespace:Foo.Bar.MyWpfApplication"

...

<Grid>
    <local:MyUserControl Grid.Row="1" x:Name="myControl" />
</Grid>

Also tried this namespace statement with not change to the issue:

xmlns:local="clr-namespace:Foo.Bar.MyWpfApplication;assembly="

Question

Has anyone had this issue and solved it?

For reference I have tried the solutions posted in this thread and they didn't work.

http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/56f933c8-a093-4c47-8e1a-cde4bb1864e9

A: 

You haven't listed VS 2008 SP1 in your environment. You should definitely have that installed. Other than that, all I can suggest is don't use the WPF designer in 2008 - it stinks.

HTH,
Kent

Kent Boogaart
I am on the latest service pack sorry for not being more specific. It is also fully patched according to WUA.
Rodney Foley
Yeah and not using the tools isn't really an option. I only have to use it for very small things that make life easier, I can do 100% of everything in XAML. I like to be able to look at it in the designer to see generally how it looks without having to run the application. Also launching Expression is not an option as it is over kill to just look at how it laid out.
Rodney Foley
A: 

This is a bug in the VS 2008 SP1, and only in large and/or complex projects. This has reportedly been corrected in Visual Studio 2010 Beta 2 which from my testing appears to be correct. Because 2010 seems to be fixed with regard to this issue I doubt they will fix this in 2008.

Rodney Foley