Windows Presentation Foundation (WPF) 项目不支持应用程序

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42886381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-13 14:02:55  来源:igfitidea点击:

Application is not supported in a Windows Presentation Foundation (WPF) project

wpfxaml

提问by user3106891

I've just created a new WPF project in the blend, pushed it on git, added mqsql drivers, rest service and nfc sdk and suddenly blend tells me that Application is not supported. The error leads me to App.xaml which is entirely unedited and looks like this:

我刚刚在 blend 中创建了一个新的 WPF 项目,将它推送到 git 上,添加了 mqsql 驱动程序、rest 服务和 nfc sdk,突然 blend 告诉我不支持应用程序。该错误将我引向 App.xaml,它完全未经编辑,如下所示:

<Application x:Class="desktop_client.App"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:local="clr-namespace:desktop_client"
         StartupUri="MainWindow.xaml">
<Application.Resources>

</Application.Resources>

The same error goes for practically any tag such as Style, Setter, ControlTemplate, Canvas, Path. nothing is supported. comparing both the xaml and the c# file to the other project I just finished which works just fine, there is no difference (other than namespace and the path, naturally)

同样的错误几乎适用于任何标签,例如 Style、Setter、ControlTemplate、Canvas、Path。什么都不支持。将 xaml 和 c# 文件与我刚刚完成的另一个项目进行比较,它工作得很好,没有区别(当然除了命名空间和路径)

I'm absolutely dumbfounded

我完全傻眼了

采纳答案by MattFisch

Try adding the following references:

尝试添加以下引用:

  • PresentationCore
  • PresentationFramework
  • WindowsBase
  • 演示核心
  • 演示框架
  • 视窗基地

With the ReferenceManager in your project. The above references are the references used by wpf.

在您的项目中使用 ReferenceManager。以上参考资料为wpf使用的参考资料。

回答by dvdhns

Had same issue in VS. I closed and restarted VS and no longer got the error.

在 VS 中有同样的问题。我关闭并重新启动 VS,不再出现错误。