Error: Cannot create an instance of xxx

1755
5
Jump to solution
01-31-2012 10:38 AM
ShaningYu
Frequent Contributor
In one of the xaml file, received such an error at the line of code:

            <userControls:GraphComparison x:Name="GraphComp"/>

Error 114 Cannot create an instance of "GraphComparison". C:\...\Views\CompareCycles.xaml 270 13

The detail shows that
Cannot find a Resource with the Name/Key CommonBorder [Line: 10 Position: 44]
   at System.Windows.Application.LoadComponent(Object component, Uri resourceLocator)
   at xxx.UserControls.GraphComparison.InitializeComponent() in C:\...\obj\Debug\UserControls\GraphComparison.g.i.cs:line 60
   at xxx.UserControls.GraphComparison..ctor() in C:\...\UserControls\GraphComparison.xaml.cs:line 20

However, I did declare:
xmlns:userControls="clr-namespace:npsNavSL.UserControls"
and found nothing wrong.  Wish can get someone's hint for this bug.  Thanks.
0 Kudos
1 Solution

Accepted Solutions
JenniferNery
Esri Regular Contributor
Please check...
If it can't find it then maybe the   XAML namespace declaration could be wrong. Another way to check is to put a break point on GraphicSource class, to see if it comes through there. Check the class namespace is the same as what you define for xmlns:userControls="...".

View solution in original post

0 Kudos
5 Replies
DominiqueBroux
Esri Frequent Contributor
It's likely an error in the XAML part of your GraphComparison user control.
0 Kudos
ShaningYu
Frequent Contributor
The GraphComparison.xmal displays well.  In the xaml page that loads the GraphComparison.xaml shows the error message in the 1st post of this thread.  How to debug it?  Thanks.
0 Kudos
JenniferNery
Esri Regular Contributor
You can check that when you type "<userControls:" in XAML, GraphicSource is shown in the intellisense. If it can't find it then maybe the XAML namespace declaration could be wrong. Another way to check is to put a break point on GraphicSource class, to see if it comes through there. Check the class namespace is the same as what you define for xmlns:userControls="...".
0 Kudos
ShaningYu
Frequent Contributor
I  typed "<userControls:" in XAML, GraphicSource is shown in the intellisense (see the image attached).  What other approaches can be used for the debug?  Thanks.
0 Kudos
JenniferNery
Esri Regular Contributor
Please check...
If it can't find it then maybe the   XAML namespace declaration could be wrong. Another way to check is to put a break point on GraphicSource class, to see if it comes through there. Check the class namespace is the same as what you define for xmlns:userControls="...".
0 Kudos