XML 命名空间中不存在标记 [英] tag does not exist in XML namespace

查看:77
本文介绍了XML 命名空间中不存在标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个错误似乎到处张贴,但每个人似乎都有自己的解决方案,但没有一个解决了我的问题.

This error seems to be posted all over the place but each one seems to have its own solution, none of which solved my problem.

我正在制作(以及稍后合并)的资源词典出现错误,即 XML 命名空间clr-namespace:Company.Project.Module.Folder;assembly=Company.Project"中不存在标记ModelBindings".模块'

I am getting an error for a Resource Dictionary I am making (and later merging) that the tag 'ModelBindings' does not exist in XML namespace 'clr-namespace:Company.Project.Module.Folder;assembly=Company.Project.Module'

我引用的程序集是自定义的并包含在解决方案中.不仅如此,我们还查看了放入资源字典所在项目的 bin 中的 dll,经过检查,它包含我想要引用的类.所以我知道 1. dll 位于可以访问的正确位置并且在引用中.2.dll中包含了我想要的数据.

The assembly I am referencing is custom and contained within the solution. Not only that but we have looked at the dll put into the bin for the project the Resource Dictionary resides in and after inspection it contains the class I want to reference. So I know that 1. the dll is in the right place to be accessed and is in references. 2. The dll contains the data I want.

这里是资源字典的一些代码

Here are some bits of code for the Resource Dictionary

命名空间列表

xmlns:modulemodel="clr-namespace:Company.Project.Module.Folder;assembly=Company.Project.Module"

创建要引用的资源

<modulemodel:ModelBindings x:Key="ModuleModelBindings"/>

就像其他人的错误一样,intellisense 说它是 kosher 的.此外,xmlns 列表是使用智能感知的自动完成功能创建的,并手动重新输入.都没有用.

Like the other people's errors the intellisense says its kosher. ALso the xmlns listing was created with intellisense's autocomplete and retyped manually. Neither worked.

我也尝试将所有内容移动到 app.xaml,但它仍然给我同样的错误.

I also tried moving everything to app.xaml and it still gave me the same error.

如果我删除 ResourceDictionary 文件的主体,代码可以正常编译,但所有绑定都被破坏了.

If I remove the body of the ResourceDictionary file the code compiles fine, but all the bindings are broken.

最后,所有资源定义过去都在使用它们的 xaml 文件中定义,效果很好.只有在我尝试从不同的项目创建它们之后,它才不起作用.我对此进行了更改以修复错误并返回到旧方法可能会出现问题.

Lastly, all the resource definitions used to be defined within the xaml files where they were used, that worked fine. Its only after I tried creating them from a different project that it didn't work. I changed this to fix an error and going back to the old method could potentially be problematic.

这是我在显示我正在使用的资源字典方面所能做的最好的事情

Here is the best I can do in terms of showing the resource dictionary I am using

<SharedResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:modulemodel="clr-namespace:Company.Project.Module.Folder;assembly=Company.Project.Module"
                    >
    <modulemodel:ModelBindings x:Key="ModuleModelBindings"/>

</SharedResourceDictionary>

如果我用 ResourceDictionary 替换 SharedResourceDictionary 会发生同样的错误.

if I replace SharedResourceDictionary with ResourceDictionary the same error occurs.

app.xaml 和上面的 SharedResourceDictionary 相对地位于 Company.Project.Main 命名空间中,它引用了 SharedResourceDictionary 的定义以及我在上面代码中放入的不同模块项目

app.xaml and the SharedResourceDictionary above are comparetively in the namespace Company.Project.Main and it has references to both where SharedResourceDictionary is defined as well as the different module projects I put into the code above

解决方案

看起来主要是用户错误.但这可能发生在其他人身上.当我从原始文件中复制 xmlns:moduleviewmodel 定义时,我必须自己添加 assembly= 部分.就像我说的那样,我既自己做,也使用自动完成输入 'xmlns:moduleviewmodel=' .就在我们发现错误之前,我们再次尝试了自动完成,因为我们发现 7 个命名空间之一没有产生错误.就在那时,我注意到汇编路径中有一个应该是大写的字母.奇怪的是自动完成实际上是自己插入这个错误.在我们编译时,我注意到了错误的字母.更奇怪的是,在我手动修复了所有路径后,我们再次尝试了自动完成,并且拼写正确.

Looks like it was mostly a user error. But this could happen to others. When I copied the xmlns:moduleviewmodel definition from its original file I had to add the assembly= portion on my own. Like I said I both did it myself as well as use the autocomplete the follows from typing 'xmlns:moduleviewmodel=' . Right before we found the error we tried the autocomplete again because we found that there was one of the 7 namespaces not generating the error. It was then that I noticed that there was a letter in assembly path that was not capitalized that should be. The weird thing is the autocomplete actually inserts this error on its own. While we were compiling that I noticed the erroneous letter. The weirder thing is that after I fixed all the paths manually we tried the autocomplete again and it spelled it correctly.

我不知道错误自动完成的原因,但使用固定字母它编译得很好.

I have no idea the cause of the errored autocomplete but with the fixed letter it compiles just fine.

现在我只是想知道是否有人会相信自动完成功能正在改变我!

Now I just wonder if anyone will believe the autocomplete was changing up on me!

推荐答案

看起来主要是用户错误.但这可能发生在其他人身上.当我从其原始文件复制 xmlns:moduleviewmodel 定义时,我必须自己添加 assembly= 部分.就像我说的那样,我既自己做,也使用自动完成输入 'xmlns:moduleviewmodel=' .就在我们发现错误之前,我们再次尝试了自动完成,因为我们发现 7 个命名空间之一没有产生错误.就在那时,我注意到汇编路径中有一个应该是大写的字母.奇怪的是自动完成实际上是自己插入这个错误.在我们编译时,我注意到了错误的字母.更奇怪的是,在我手动修复了所有路径后,我们再次尝试了自动完成,并且拼写正确.

Looks like it was mostly a user error. But this could happen to others. When I copied the xmlns:moduleviewmodel definition from its original file I had to add the assembly= portion on my own. Like I said I both did it myself as well as use the autocomplete the follows from typing 'xmlns:moduleviewmodel=' . Right before we found the error we tried the autocomplete again because we found that there was one of the 7 namespaces not generating the error. It was then that I noticed that there was a letter in assembly path that was not capitalized that should be. The weird thing is the autocomplete actually inserts this error on its own. While we were compiling that I noticed the erroneous letter. The weirder thing is that after I fixed all the paths manually we tried the autocomplete again and it spelled it correctly.

我不知道错误自动完成的原因,但使用固定字母它编译得很好.

I have no idea the cause of the errored autocomplete but with the fixed letter it compiles just fine.

现在我只是想知道是否有人会相信自动完成功能正在改变我!

Now I just wonder if anyone will believe the autocomplete was changing up on me!

这篇关于XML 命名空间中不存在标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆