Home > Posts > Fix: The tag XXX does not exist in XML namespace ‘clr-namespace:YYY’

Fix: The tag XXX does not exist in XML namespace ‘clr-namespace:YYY’

I just had some big trouble troubleshooting the Visual Studio / XAML compiler error message:

The tag XXX does not exist in XML namespace ‘clr-namespace:YYY’

It turned out this occurred because I had a Silverlight library with Assembly name X and default namespace X (at properties pane), but was using it from a demo project with Assembly name X (again!) and default namespace X.

If I removed the ";assembly=X" part from the XAML it worked fine, that is:

xmlns:my="clr-namespace:X"

Fixing the demo project to use Assembly name X.Demo and default namespace X.Demo (at its Properties pane), instead of having the same assembly name, now allows me to also use

xmlns:my="clr-namespace:X;assembly=X"

without problem.

Seems that when you have multiple assemblies with the same name in a project (wonder how the filesystem supports that), all of them are loaded fine and if they have classes with namespace X in them, the namespace gets classes from both assemblies (that’s why the xmlns without assembly=… works). When you specify assembly name in the XAML of a given project, it assumes you mean its own assembly, not any other referenced one with the same name.

BTW, at add references dialog I was using Projects option (to reference the output of other project in solution) and the project I was referencing was named X.Silverlight (can be named anything), I had not added reference the X assembly .dll file directly. Maybe that played its part too in the issue.

There may be other cases too that can cause this error to fire up, see:

http://social.msdn.microsoft.com/Forums/en/wpf/thread/56f933c8-a093-4c47-8e1a-cde4bb1864e9

  1. Hugo
    2014/06/11 at 17:05

    Great that help me a lot!
    Removing the “;assembly=X” part from the XAML it worked fine

  2. Aashish Upadhyay
    2014/10/07 at 13:16

    great thanks

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: