2008-06-08

XamlParseException in WPF

When hacking WPF one sometimes get
System.Windows.Markup.XamlParseException was unhandled
Message="Cannot create instance of 'FormMain' defined in assembly 'Kopain2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'. Exception has been thrown by the target of an invocation. Error in markup file 'Forms/FormMain.xaml' Line 1 Position 9.

which does not give much of a clue.



So copy exception details to your favourite editor (Copy exception detail to the clipboard...) and scroll down. Typically at the second last row you can read something like
at Kopain2.FormMain..ctor() in C:\Data\Projects\Kopain2\Kopain2\Forms\FormMain.xaml.cs:line 101
which is a magnitude more helpful.

1 comment:

Dan Lamping said...

You can always put MarkupSource tracing on. This tends to help.

http://www.wpfmentor.com/2009/01/how-to-find-out-what-that.html