I have started using Blend with silverlight and I seem to come across this error frequently. Here is a screenshot (its quite large and will need scrolling)
This happens when I create a user control and add this to my page.xaml I get the error "cannot create instance of" within design view, but it will still build and test fine. Restarting / re-opening and even reinstalling blend does nothing to solve the issue.
I've created the usercontrol "keyboard controls" which is a bunch of listitems with stylings. Then added the usercontrol via the assets library. This is then embedded into the page.xaml which then gives me the error above. Is this correct?
While we have made a number of improvments to Blend since the Blend 2.5 June Preview in Blend 2 Sp1, it is likely that exceptions might be thrown in user code. Here is a way to debug such issues quickly:
I was having the same problem. Two of my usercontrols did not want to render in their containing page and was I getting the same 'cannot create an instance of [x]' exception.
I'd discovered that some controls inside these two usercontrols were using the same Style (Style="{StaticResource GenericHyperlinkButtonStyle}")
Once I'd removed the style, they started working as usual.
I do not know the cause of the issue but I will create a new style and work from that.
Amendment:
I've come across this issue again when using BorderBrush="{StaticResource GenericBorderBrush}".
'GenericBorderBrush' is defined in App.xaml. It finally worked after I'd move the definition of 'GenericBorderBrush' to the top of the document (it was the last definition). So I can now keep the use of BorderBrush="{StaticResource GenericBorderBrush}".
I'm assuming that there is an incorrect definition in the App.xaml which causes the definitions below it to fail.
mattratcliffe
0 Points
2 Posts
cannot create an instance of "x"
Aug 12, 2008 12:25 PM | LINK
Hi there
I have started using Blend with silverlight and I seem to come across this error frequently. Here is a screenshot (its quite large and will need scrolling)
screenshot
This happens when I create a user control and add this to my page.xaml I get the error "cannot create instance of" within design view, but it will still build and test fine. Restarting / re-opening and even reinstalling blend does nothing to solve the issue.
Any help, advice would be much appreciated.
cheers
Matt
Shaji-mji
Participant
1141 Points
263 Posts
Re: cannot create an instance of "x"
Aug 12, 2008 12:51 PM | LINK
are you trying to add the same usercontrol inside it?
(http://visual-studio2008.blogspot.com )
Collection Of Emails
mattratcliffe
0 Points
2 Posts
Re: cannot create an instance of "x"
Aug 12, 2008 01:04 PM | LINK
Hi ,
I've created the usercontrol "keyboard controls" which is a bunch of listitems with stylings. Then added the usercontrol via the assets library. This is then embedded into the page.xaml which then gives me the error above. Is this correct?
thanks
Matt
Nenong
Member
21 Points
15 Posts
Re: cannot create an instance of "x"
Aug 14, 2008 06:21 AM | LINK
I also have met this problem, and hope someone can solve it[:-*]
The UserControl does not show right in Blend, but it can show in VisualStudio. So every time I open both Blend and VisualStuio.
And on the left/buttom of IE, there is an error icon(ScreenShot) , is this also because of the "Cannot create instance of ***".
error icon create instance
sleary
Member
2 Points
1 Post
Re: cannot create an instance of "x"
Sep 09, 2008 02:26 PM | LINK
GOT IT!!!!
Check the xaml for event attributes (i.e. Click="myClickHandler") chances are they don't line up with the associated methods in the code behind.
unnir
Member
62 Points
21 Posts
Re: cannot create an instance of "x"
Sep 27, 2008 07:33 AM | LINK
While we have made a number of improvments to Blend since the Blend 2.5 June Preview in Blend 2 Sp1, it is likely that exceptions might be thrown in user code. Here is a way to debug such issues quickly:
http://blogs.msdn.com/expression/archive/2008/06/19/debugging-design-time-exceptions.aspx
Thanks,
Unni
ahura mazda
Member
40 Points
5 Posts
Re: cannot create an instance of "x"
Oct 30, 2008 12:54 PM | LINK
Hi,
I was having the same problem. Two of my usercontrols did not want to render in their containing page and was I getting the same 'cannot create an instance of [x]' exception.
I'd discovered that some controls inside these two usercontrols were using the same Style (Style="{StaticResource GenericHyperlinkButtonStyle}")
Once I'd removed the style, they started working as usual.
I do not know the cause of the issue but I will create a new style and work from that.
Amendment:
I've come across this issue again when using BorderBrush="{StaticResource GenericBorderBrush}".
'GenericBorderBrush' is defined in App.xaml. It finally worked after I'd move the definition of 'GenericBorderBrush' to the top of the document (it was the last definition). So I can now keep the use of BorderBrush="{StaticResource GenericBorderBrush}".
I'm assuming that there is an incorrect definition in the App.xaml which causes the definitions below it to fail.
Hope this helps you.
ahura