locked
XAML compile error: The tag '{0}' does not exist in XML namespace '{1}' RRS feed

  • 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:

    1. Create new Silverlight Class Library "ClassA"
    2. Add a reference to .NET assembly: "System.Json" (Copy To Local = False, Specific Version = False)
    3. Add an interface that use this assembly (for example):
       public interface IJson
       {
       void FromJson(JsonObject json);
       JsonObject ToJson();
       }
      
    4. Add another Silverlight Class Library "ClassB" to implement the interface.
    5. Add an empty public constructor to allow creating an instance in XAML.
    6. Add a reference to .NET assembly: "System.Json" (Copy To Local = False, Specific Version = False)
    7. Add a reference to project "ClassA"
    8. Add a Silverlight Application that will use ClassB in XAML.
    9. Add a reference to projects "ClassA" and "ClassB"
    10. 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>
      
    11. 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>
    
    

     

    Thanks!
    Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)
    Friday, December 23, 2011 10:48 PM

All replies