Answered by:
XAML compile error: The tag '{0}' does not exist in XML namespace '{1}'

Question
-
I've included this a zipped project to SkyDive: https://skydrive.live.com/?cid=e0300799ba873ec7&sc=documents&id=E0300799BA873EC7!126
Summary: When a library implements an interface from another library that requires an assembly, creating an instance of this class in XAML throws an error that it does not exist in XML namespace.
There had been similar threads to this but there was no answer to fix the issue.
To reproduce:
- Create new Silverlight Class Library "ClassA"
- Add a reference to .NET assembly: "System.Json" (Copy To Local = False, Specific Version = False)
- Add an interface that use this assembly (for example):
public interface IJson { void FromJson(JsonObject json); JsonObject ToJson(); }
- Add another Silverlight Class Library "ClassB" to implement the interface.
- Add an empty public constructor to allow creating an instance in XAML.
- Add a reference to .NET assembly: "System.Json" (Copy To Local = False, Specific Version = False)
- Add a reference to project "ClassA"
- Add a Silverlight Application that will use ClassB in XAML.
- Add a reference to projects "ClassA" and "ClassB"
- Add the following code to MainPage.xaml
xmlns:b="clr-namespace:ClassB;assembly=ClassB" xmlns:a="clr-namespace:ClassA;assembly=ClassA"> <Grid x:Name="LayoutRoot" Background="White"> <ListBox> <b:Class1/> </ListBox> </Grid> </UserControl>
- Build the solution. Notice XAML-compile error: The tag 'Class1' does not exist in XML namespace 'clr-namespace:ClassB;assembly=ClassB'
This error goes away when reference to "System.Json" is added to the Silverlight Application or reference to projects ClassA and ClassB are removed and added again.
The issue is the XAML compile error is misleading and is not descriptive of what could really be wrong. If required assemblies need to be referenced in the project, this error does not indicate it.
Jennifer Nery
- Moved by Lie You Monday, August 1, 2011 7:53 AM Silverlight related, and already post the same issue to the Silverlight forum. (From:Visual C# General)
- Edited by jennifernery Tuesday, August 2, 2011 1:51 AM Added link to SkyDive
Wednesday, July 27, 2011 11:34 PM
Answers
-
This was moved out of the VC# forum.
I can move it into a specific Silverlight forum if you'd like.
This is regarding your code:
xmlns:b="clr-namespace:ClassB;assembly=ClassB" xmlns:a="clr-namespace:ClassA;assembly=ClassA"> <Grid x:Name="LayoutRoot" Background="White"> <ListBox> <b:Class1/> </ListBox> </Grid> </UserControl>
Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)- Edited by Ed Price - MSFTMicrosoft employee Friday, December 23, 2011 10:48 PM
- Proposed as answer by Ed Price - MSFTMicrosoft employee Friday, December 23, 2011 10:48 PM
- Marked as answer by Ed Price - MSFTMicrosoft employee Friday, December 23, 2011 10:49 PM
Friday, December 23, 2011 10:48 PM
All replies
-
This might help
chanmm
chanmmThursday, July 28, 2011 9:03 AM -
Thanks but that blog post is not related.
Jennifer NeryFriday, July 29, 2011 4:56 AM -
Welcome to the MSDN Forum.
I suggest you to post this issue to the following more appropriate forums for more efficient responses.
Silverlight.NET Forums : The Official Microsoft Silverlight.NET Forums
Hope it helps.
Best Regards,
Rocky Yue[MSFT]
MSDN Community Support | Feedback to us
Get or Request Code Sample from Microsoft
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Friday, July 29, 2011 7:55 AM -
What it's worth, I can't reproduce this in VS2010 and Silverlight 4.
Friday, July 29, 2011 8:57 AM -
Thank you, I already posted in the Silverlight forums.
Jennifer NeryMonday, August 1, 2011 1:21 AM -
I am also using VS 2010 and Silverlight 4. I've followed these steps and was able to reproduce the issue every time. I think the key is referencing System.Json as (CopyToLocal=False) in both projects (ClassA & ClassB), having an interface that use System.Json defined in ClassA that is implemented in ClassB. An instance of ClassB cannot be created in XAML without compile error.
Jennifer NeryMonday, August 1, 2011 1:25 AM -
This was moved out of the VC# forum.
I can move it into a specific Silverlight forum if you'd like.
This is regarding your code:
xmlns:b="clr-namespace:ClassB;assembly=ClassB" xmlns:a="clr-namespace:ClassA;assembly=ClassA"> <Grid x:Name="LayoutRoot" Background="White"> <ListBox> <b:Class1/> </ListBox> </Grid> </UserControl>
Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)- Edited by Ed Price - MSFTMicrosoft employee Friday, December 23, 2011 10:48 PM
- Proposed as answer by Ed Price - MSFTMicrosoft employee Friday, December 23, 2011 10:48 PM
- Marked as answer by Ed Price - MSFTMicrosoft employee Friday, December 23, 2011 10:49 PM
Friday, December 23, 2011 10:48 PM