应用程序正常运行但出现“错误"在设计时:“命名空间中不存在"和“查找资源字典时发生错误"; [英] App runs normally but has "errors" during design time: "does not exist in namespace" and "an error occured when finding the resource dictionary"

查看:34
本文介绍了应用程序正常运行但出现“错误"在设计时:“命名空间中不存在"和“查找资源字典时发生错误";的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序在设计时的错误框中有某些错误,与它的资源字典有关.例如,在我的主窗口中,资源字典的调用方式如下;

My application has certain errors, in its error box during design time, to do with it's resource dictionary. For example, in my Main Window a resource dictionary is called as follows;

<Window.Resources>
    <ResourceDictionary Source="Resources.xaml"/>
</Window.Resources>

我在中间一行看到一条蓝线,上面写着查找资源字典Resources.xaml"时出错.然而,Resources.xaml 位于项目的根文件夹中,MainWindow 也是如此.

I get a blueline on the middle line saying "An error has occurred while finding the resource dictionary "Resources.xaml". Yet, the Resources.xaml is in the root folder of the project, and so is the MainWindow.

我知道那里有类似的问题,但是答案是;

I am aware that there are similar questions like this out there, however the answers;

确保将 Resources.xaml 设置为构建操作:页面"

"Make sure Resources.xaml is set to build action: page"

确保您正确引用了 Resources.xaml"

"Make sure you are correctly referencing Resources.xaml"

对我没有帮助.

我还有一个问题,在资源字典中,我有错误提示;

I have an additional problem in that, within the resource dictionary, I have errors telling me;

the name ProductDatabaseViewModel does not exist in the namespace "clr-namespace:gate2software.ViewModels"

同理;

the name ProductDatabaseView does not exist in the namespace "clr-namespace:gate2software.Views"

在下面的xaml中;

<DataTemplate DataType="{x:Type vm:ProductDatabaseViewModel}">
    <vw:ProductDatabaseView />
</DataTemplate>

实际上,这两种方法都可以在它们声明的位置使用.

In reality both of these are available exactly where they are stated to be.

对于我的两个问题中的任何一个的任何建议将不胜感激.

Any suggestions for either of my two problems would be greatly appreciated.

推荐答案

我刚刚遇到了同样的问题.我的项目是针对 x64 构建的.我将它们更改为 Any CPU 见下文,并且能够在设计时看到我的视图模型数据.

I just ran into this same issue. My projects were targeted for a x64 build. I changed them to Any CPU See below and was able to see my view model data at design time.

这篇关于应用程序正常运行但出现“错误"在设计时:“命名空间中不存在"和“查找资源字典时发生错误";的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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