错误:项目文件必须在参考列表中包含 .NET Framework 程序集“WindowsBase、PresentationCore、PresentationFramework" [英] Error: Project file must include the .NET Framework assembly 'WindowsBase, PresentationCore, PresentationFramework' in the reference list

查看:54
本文介绍了错误:项目文件必须在参考列表中包含 .NET Framework 程序集“WindowsBase、PresentationCore、PresentationFramework"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 C# 的 Windows 窗体应用程序中使用 WPF.

I am using WPF in a Windows Forms Application with C#.

跟进问题.添加实线、虚线的集合笔到组合框

错误:

项目文件必须在参考列表中包含 .NET Framework 程序集WindowsBase、PresentationCore、PresentationFramework".

Project file must include the .NET Framework assembly 'WindowsBase, PresentationCore, PresentationFramework' in the reference list.

请推荐

推荐答案

这是一个老问题,但为了保持此资源的有效性:确实可以添加像这样的引用,正如罗斯和里德所建议的,但我认为这不是真正的解决方案,您只是在解决问题的影响,而不是原因.

It's an old question, but for the purpose of keeping this resource a valid one: it is true that you can add references likes this, as Ross and Reed suggest, but I do not believe that this is the actual solution, you're just fixing the effect of an issue, not the cause.

正如@dumbledad 所说,当我在项目中包含在 .csproj 文件中标记为页面"的文件时,我收到了完全相同的错误消息,导致 Visual Studio 想要编译此资源.然而,这是一个不可编译的资源(在我的例子中它是一个 XAML 文件,也可能是一个图像)Visual Studio 要求额外的程序集.在这种情况下,不要只是添加它们,而是进入您的 .csproj 文件并进行以下调整:

Exactly like @dumbledad says, I got the exact same error message when I included files in my project that got marked as a 'Page' in the .csproj file, resulting in Visual Studio wanting to compile this resource. However, this being an uncompilable resource (in my case it was a XAML file, could be an image as well) Visual Studio asks for extra assemblies. In this case, do not just add them, but go into your .csproj file and make the following adjustment:

搜索打开节点<Page"并验证它的每个实例实际上是一个需要用相应操作处理的页面.就我而言,如您所见,资源被标记为页面,VS 尝试编译该页面:

Search for the opening node '<Page' and verify that each instance of it actually is a page that needs to treated with the corresponding action. In my case, as you can see, a resource is marked as a Page, which VS tries to Compile:

<ItemGroup>
  <Page Include="sitecore\shell\ClientBin\EmptySplashScreen.xaml">
    <Generator>MSBuild:Compile</Generator>
  </Page>
</ItemGroup>

只需删除此部分(或页面节点)并将文件放回 .csproj 文件作为常规内容包含.您必须手动执行此操作,因为在 VS 中包含文件会重新生成相同的错误页面节点.所以我把它放回项目文件中,如下所示:

Just remove this section (or Page-node) and put the file back into the .csproj file as a regular content include. You have to do this manually, as including the file from within VS regenerates the same faulty Page-node. So I've put it back into the project file like this:

<Content Include="sitecore\shell\ClientBin\EmptySplashScreen.xaml" />

瞧,您的项目将再次构建,错误消息将消失,而无需添加那些额外的程序集引用.

Et voila, your project will build again and the error message disappears without having to add those extra assembly references.

这篇关于错误:项目文件必须在参考列表中包含 .NET Framework 程序集“WindowsBase、PresentationCore、PresentationFramework"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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