13

I have the following:

Error! Error!

The error says The 'clr-namespace' URI refers to a namespace '{0}' that is not included in the assembly.

I've build and rebuild but nothing happens. I'm sure this must work, because a WPF demo app that I downloaded has everything the same. What's going on?

Garth Marenghi
  • 1,857
  • 4
  • 18
  • 34
  • 2
    What’s going on is that the designer is a little rough around the edges and has a bunch of issues like that. In other words, it’s not you, it’s Visual Studio. – Roman Starkov Mar 17 '12 at 12:07

10 Answers10

24

Assuming your ViewModel folder isn't empty (or there actually is a type with BlooblieBlablie.ViewModel as its namespace), and BlooblieBlablie is the assembly name, the following should work:

xmlns:vm="clr-namespace:BlooblieBlablie.ViewModel;assembly=BlooblieBlablie"
Willem van Rumpt
  • 6,260
  • 2
  • 28
  • 43
  • 1
    The assembly part is not necessary as the namespace is in the same assembly as the XAML file. – Daniel Hilgarth Mar 29 '11 at 09:16
  • Ah, I got the idea because of what you said: "or there actually is a type with BlooblieBlablie.ViewModel as its namespace". This is what the problem was - The class in the ViewModel folder actually needed an AssemblyName that was AssemblyName.ViewModel. Then it should work – Garth Marenghi Mar 29 '11 at 09:26
  • @Daniel: Ah, didn't know that, to be honest. I started out specifying the assembly part from the beginning, and kept on doing it ever since. – Willem van Rumpt Mar 29 '11 at 10:23
10

I had similar problem when project's solution platform was set to x64. When I changed it to x86 problem went away.

Here is some explanation: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/6379d330-f382-4b4d-a690-e89326ab4c72

2

I had the same problem and solved it by not having my project in a path with hash-mark.

E.g D:#Temp had to be D:\Temp

I guess there's someone at Microsoft having missed an EscapedCodeBase in conjunction with the URI.

slang
  • 580
  • 5
  • 26
Daniel
  • 7,553
  • 4
  • 32
  • 46
1

I got this after Windows 7 computer crash when I was in solution in Visual Studio 2008. It seems to have blanked out the start-up configuration. I reset this and then it could find the name-space. This is one cause - probably not the major one - but just in case you have same.

Eric C
  • 11
  • 1
1

I had the same error message given to me. But the underlying problem was different. I moved my MainWindow.xaml to a different folder, and I forgot to update my App.xaml StartupUri. I then updated my StartupUri in my App.xaml and the problem was fixed.

Cloud9999Strife
  • 2,766
  • 2
  • 27
  • 40
1

Also verify the "BuildAction" of the .xaml files (see file properties). Should be "Page". After I moved files and renamed the namespace this setting changed somehow to "CodeAnalysisDictionary". This also leeds to this error.

1

Well, as far as I can see, that namespace simply doesn't exist ;-) In your ViewModel folder is no file. And without file, there is no namespace. Namespaces are not defined by folder structure but inside source files.

Daniel Hilgarth
  • 159,901
  • 39
  • 297
  • 411
1

Judging from your screenshot, your ViewModel folder seems to be empty. If there are no classes in the namespace BlooblieBlablie.ViewModel, the namespace does not exist yet.

Heinzi
  • 151,145
  • 51
  • 326
  • 481
  • I made this screenshot to be a little bit easier to look at. In my real application I do have something in my ViewModel folder, namely a class called ViewModel.cs. – Garth Marenghi Mar 29 '11 at 09:20
0

I've had the same issue, mine was self inflicted due to copying and pasting code from another source into my project and renaming objects as I went without building first.

So, this means Visual Studio or the compiler do not pick up on incorrect references (eg, in my code I had this:

MyObect mo = new MyObect();

When I copied the code over, I corrected the spelling of MyObect to MyObject but, Visual Studio has still referencing MyObect and didn't give any warnings about this. And this was code was part of a .XAML file and as such, I was not only getting the error message you were, but also .g.cs errors too. All of them pointing to the incorrect reasons.

This was also occuring in the ResourceDictionary (within my datatemplate declarations for all my VM binding)

Dave
  • 7,614
  • 10
  • 56
  • 99
0

I had the same problem today after I had to rename class (and file with it) in the namespace. So I was able to solve it by deleting .sln file, then run .csproj and recreate .sln file.

user711227
  • 13
  • 5