XAML XMLNS: Local C #

I am working on a 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"> 

Local string xmlns: complains that the WPFMVVM assembly is not referenced. Although this is the assembly in which I work.

Does anyone know why?

thanks

+6
source share
4 answers

You should not have spaces, and if this is the assembly you are working in , just do not specify assembly .

 xmlns:local="clr-namespace:WPFMVVM" 

The assembly parameter is for reference assemblies. Also see the MSDN Article in XAML Namespaces .

the assembly can be omitted if the specified clr namespace is defined in the same assembly as the application code that references custom classes. Or the equivalent syntax for this case is to specify assembly =, without the string character following the equal sign.

+12
source

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 the Create button. After the assembly was completed, the errors disappeared. I'm not an xaml expert or anything like that, but looking at the code, he says xmlns: myns = "clr-namespace: somethingorother". If it is a clr namespace, then it must be compiled for it to exist.

+4
source

There is an error in the xaml builder. On the first attempt to build, the error does not lead to the creation of all req'd files in debug \ obj. In a second attempt to build more files are created in debug \ obj, but not everything is required for xaml. If you create the third time, all the files that should be in debug \ obj are finally created, and xaml compiled.

That is why when cleaning or restoring a solution, the problem arises again until you create / build the solution.

This is only a problem when the namespace is in the same assembly as xaml. If the namespace is in a different assembly and another assembly exists, you will receive a successful assembly. If another assembly does not exist, then obviously the assembly will fail.

+2
source

Known issue. You are working on a 64-bit machine. Just set up the x86 build configuration when developing the process.

+2
source

Source: https://habr.com/ru/post/889873/


All Articles