App runs normally but has “errors” during design time: “does not exist in namespace” and “an error occured when finding the resource dictionary”

限于喜欢 提交于 2020-01-25 23:56:11

问题


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>

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;

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

"Make sure you are correctly referencing Resources.xaml"

were not helpful to me.

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"

and similarly;

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

in the following 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.


回答1:


make sure your path is correct? or try like dis path:

<ResourceDictionary Source=ms-appx:///CustomControls/Resources.xaml>



回答2:


Have you tried to close the designer process (sometimes this works)? Task Manager > Details > XDesProc.exe > end process. You will be able to reload it by clicking refresh in any VS view, but first rebuild all.

And by the way, Resources.xaml is for sure a ResourceDictionary type and not Page ? This kind of errors are shown also when you try to add a page as resource, not a ResourceDictionary.




回答3:


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.



来源:https://stackoverflow.com/questions/29150253/app-runs-normally-but-has-errors-during-design-time-does-not-exist-in-namesp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!