The tag 'XXX' does not exist in XML namesp

2020-06-01 06:18发布

I have implemented a converter to convert Int32 to String to be able to binding a property to a textBox.

I implement this converter in the namespace MyApp.Converters and it is called Int32ToStringConverter.

Then, in my axml I add the reference to my converter as follow:

<Window x:Class="MusicaDB.Views.PrincipalView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:i="namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
        **xmlns:converter="clr-namesapce:MyApp.Converters, aseembly=MyApp**">

Later, in windows.Resources I have:

<Window.Resources>
        <**converter:Int32ToStringConverter** x:Key="Int32ToStringConverter" />
</Window.Resources>

I get the error that the tag Int32ToString converter does not exist in the namespace MyApp.Converters,assembly=MyApp.

I have the project in the local hard drive, in the project properties, the destination .NET is framework 4.0, not framework 4.0 client profile and I try to clear the solution and recompile but the problem persists.

Mainly, this is the two solutions that I always find, but don't resolve my problem.

标签: wpf xaml
10条回答
爷的心禁止访问
2楼-- · 2020-06-01 06:56

Three fixes to make here:

  1. No spaces -> xmlns:converter="clr-namesapce:MyApp.Converters,aseembly=MyApp"
  2. No misspellings -> xmlns:converter="clr-namespace:MyApp.Converters,assembly=MyApp"
  3. Right delimiters -> xmlns:converter="clr-namespace:MyApp.Converters;assembly=MyApp"

From the the documentation:

Note that the character separating the clr-namespace token from its value is a colon (:) whereas the character separating the assembly token from its value is an equals sign (=). The character to use between these two tokens is a semicolon. Also, do not include any whitespace anywhere in the declaration.

查看更多
smile是对你的礼貌
3楼-- · 2020-06-01 06:58

Another possible solution to this problem is that you're not using the same version of .Net in your project and your library.

查看更多
\"骚年 ilove
4楼-- · 2020-06-01 07:01

All answers are right. And after trying all of them and you cannot configure why its happening, everything seems alright, Please restart the Visual studio.

That worked for me after wasting almost 1 hour. I found everything ok, but restarted the VS with administration.

查看更多
做自己的国王
5楼-- · 2020-06-01 07:05

use the assemble tag only if it is in another project. other wise use just namespace tag alone. For me this fixed the issue

查看更多
我欲成王,谁敢阻挡
6楼-- · 2020-06-01 07:06

I am exploring as to why this is happening, but if your converter is in the main assembly, removing the assembly= from your xmlns:converters tag should remove that build error.

查看更多
贪生不怕死
7楼-- · 2020-06-01 07:09

I see two possible causes. The first is that you misspelled "assembly" as "aseembly" in the first starred line. Changing the spelling might be enough. The second possibility is that you haven't added MyApp.dll to your project references, which appear like this

enter image description here

in Visual Studio.

查看更多
登录 后发表回答