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

查看:60
本文介绍了标记在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.

我在制作(后来合并)资源字典时出错,标签"ModelBindings"在XML名称空间"clr-namespace:Company.Project.Module.Folder; assembly = Company.Project"中不存在.Module'

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"/>

就像其他人的错误一样,智能感知说它是犹太洁食.同样,xmlns列表是使用intellisense的自动完成功能创建的,并手动重新键入.都不起作用.

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>

如果将SharedResourceDictionary替换为ResourceDictionary,则会发生相同的错误.

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

解决方案

Solution

看起来主要是用户错误.但这可能会发生在其他人身上.当我从其原始文件复制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天全站免登陆