I am working through an MVVM tutorial, and I have the following code, written in Xaml:
<Window x:Class="WPFMVVM.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WPFMVVM; assembly=WPFMVVM"
Title="MainWindow" Height="388" Width="545">
The xmlns:local line is complaining saying that WPFMVVM assembly is not referenced. Although it is the assembly that I am working in.
Anybody know why?
Thanks
You must not have spaces in there & if it's the assembly you work in just do not specify assembly
.
xmlns:local="clr-namespace:WPFMVVM"
The assembly
parameter is for referenced assemblies. Also see the MSDN article on XAML namespaces.
assembly can be omitted if the clr-namespace referenced is being defined within the same assembly as the application code that is referencing the custom classes. Or, an equivalent syntax for this case is to specify assembly=, with no string token following the equals sign.
Not sure if this will help or not, but I had the same problem and managed to fix it on two different projects. I right clicked on the project and clicked build. Once the build was completed, the errors were gone. I'm no xaml expert or anything, but looking at the code, it says xmlns:myns="clr-namespace:somethingorother". If its a clr-namespace, then it must be compiled in order for it to exist.
There is a bug in the xaml builder.
On the first attempt to build, the failure causes not all req'd files in debug\obj to be created.
On the second attempt to build, more files are created in debug\obj, but not all that are req'd for the xaml.
If you build a 3rd time, then all files that are supposed to be in debug\obj are finally created, and the xaml will compile.
Which is why when you clean or rebuild the solution, the problem reappears until you build/build the solution.
This is only a problem when the namespace is in the same assembly as the xaml. If the namespace is in another assembly, and the other assembly exists, then you will get a successful build. If the other assembly does not exist, then obviously the build will fail.
There is known issue.
You are working on 64 bit machine. Simply set x86 build configuration at developing process.