问题描述
我正在尝试在'.NETFramework,Version = v4.5.2'应用程序中用C#编写一些单元测试,但是所有测试都会给出下一个错误:
I am trying to write some unit tests in C# in a '.NETFramework,Version=v4.5.2' application but all tests give the next error:
当我尝试安装 System.Drawing.Common
时,我从NuGet包中收到下一个错误:
When I try to install System.Drawing.Common
I get the next error from the NuGet package:
无法安装软件包"System.Drawing.Common 4.5.1".您正在尝试将此软件包安装到针对的项目中'.NETFramework,Version = v4.5.2',但该软件包不包含任何与该框架兼容的程序集引用或内容文件.欲了解更多信息,请与软件包作者联系.
Could not install package 'System.Drawing.Common 4.5.1'. You are trying to install this package into a project that targets'.NETFramework,Version=v4.5.2', but the package does not contain any assembly references or content files that are compatible with that framework. For moreinformation, contact the package author.
我无法更改应用程序版本或框架(.NET Core 2.1),并且我在网上发现的任何其他窍门均无效(或产生了更多错误).
I cannot change the application version or the framework (.NET Core 2.1) and any other trick I found online did not work (or generated more errors).
帮助?
更新:我设法通过重新启动Visual Studio,将框架更改为4.6.1(以前无法做到)并添加引用来解决此问题.很抱歉,不清楚的解释,我是新手,对我来说Visual Studio的工作方式很神秘.谢谢大家
UPDATE: I managed to solve it by restarting Visual Studio, changing the framework to 4.6.1 (which I could not do before) and adding the reference. Sorry for the unclear explanations, I'm a newbie, and to me Visual Studio works in mysterious ways. Thanks everyone
推荐答案
放在这一行:安装包System.Drawing.Common-版本4.5.2
in NuGet put this line : Install-Package System.Drawing.Common -Version 4.5.2
放在:dotnet添加软件包System.Drawing.Common --version 4.5.2
in .NET CLI put : dotnet add package System.Drawing.Common --version 4.5.2
放在:paket添加System.Drawing.Common --version 4.5.2
in Paket CLI put : paket add System.Drawing.Common --version 4.5.2
这篇关于如何在使用'.NETFramework,Version = v4.5.2'的项目中安装System.Drawing.Common?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!