如何在使用'.NETFramework,Version = v4.5.2'的项目中安装System.Drawing.Common? [英] How do I install System.Drawing.Common in a project that uses '.NETFramework,Version=v4.5.2'?

查看:263
本文介绍了如何在使用'.NETFramework,Version = v4.5.2'的项目中安装System.Drawing.Common?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在'.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.IO.FileNotFoundException:无法加载文件或程序集'System.Drawing.Common,版本= 0.0.0.0,文化=中性,PublicKeyToken = cc7b13ffcd2ddd51'.系统找不到文件指定.'

'System.IO.FileNotFoundException : Could not load file or assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.'

当我尝试安装 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 more information, 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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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