简体   繁体   English

.NET System.Drawing.Common 4.5.1 的 NuGet 包包含不正确的程序集版本

[英]NuGet package for .NET System.Drawing.Common 4.5.1 contains incorrect version of assemblies

I am trying to use System.Drawing.Common in project depending on (legacy) .NET Standard 2.0.我正在尝试根据(旧版).NET Standard 2.0 在项目中使用System.Drawing.Common If I try to target Standard 2.1, I experience compatibility issues with one of my dependencies, pythonnet , so I need to stick to 2.0 until pythonnet has official support for .NET Standard.如果我尝试以 Standard 2.1 为目标,我的依赖项之一pythonnet 会遇到兼容性问题,因此我需要坚持使用 2.0,直到 pythonnet 正式支持 .NET Standard。 Currently, pythonnet can import my assemblies if they target .NET Standard 2.0, but won't for .NET Standard 2.1.目前,如果我的程序集面向 .NET Standard 2.0,pythonnet 可以导入我的程序集,但不适用于 .NET Standard 2.1。

For .NET Standard 2.0 compatibility, the most recent package available is System.Drawing.Common 4.5.1 .对于 .NET Standard 2.0 兼容性,可用的最新包是System.Drawing.Common 4.5.1 After installing this, my solution builds but at runtime I receive the error安装后,我的解决方案构建但在运行时我收到错误

System.PlatformNotSupportedException: 'System.Drawing is not supported on this platform.'

According to this page , this version of the System.Drawing.Common package should be able to target .NET Standard 2.0.根据这个页面,这个版本的System.Drawing.Common包应该能够针对 .NET Standard 2.0。 I found that the NuGet package contains several System.Drawing.Common.dll files for different platforms, but a file version of 4.6.2.我发现NuGet 包中包含多个针对不同平台的System.Drawing.Common.dll文件,但文件版本为4.6.2。

NuGet 包包含不匹配的程序集版本

Am I missing something or is this an error in the NuGet package?我是否遗漏了什么或者这是 NuGet 包中的错误? It seems like this would be the case.情况似乎是这样。

The version numbers isn't a problem.版本号不是问题。 There's no requirement or guarantee that any of the Assembly Version, File Version, or Package Version all match.不要求或保证任何程序集版本、文件版本或包版本都匹配。

The PlatformNotSupportedException will be coming from some other problem, though looking through the package I'm not quite sure what. PlatformNotSupportedException 将来自其他一些问题,尽管查看包我不太确定是什么。 A lot depends on how your project is actually built and run.在很大程度上取决于您的项目的实际构建和运行方式。

My problem was that I had 2 .NET Core App projects and one was dependent on the other (So that I can execute the app from the other app) .我的问题是我有2 个 .NET Core App 项目,一个依赖于另一个(以便我可以从另一个应用程序执行该应用程序) The thing with .NET Core applications is that they need additional files to work (like <assembly name>.deps.json (which was the culprit) and <assembly name>.runtimeconfig.json ) and for some reason they don't get copied on build . .NET Core 应用程序的问题是它们需要额外的文件才能工作(例如<assembly name>.deps.json (这是罪魁祸首)<assembly name>.runtimeconfig.json )并且由于某种原因他们没有得到在构建时复制


Crude solution I did was adding copy command to the dependent project's build events like this我所做的粗略解决方案是将复制命令添加到依赖项目的构建事件中

COPY "$(SolutionDir)<dependency project>\$(OutDir)<assembly name>.runtimeconfig.json" "$(SolutionDir)$(ProjectName)\$(OutDir)" /Y
COPY "$(SolutionDir)<dependency project>\$(OutDir)<assembly name>.deps.json" "$(SolutionDir)$(ProjectName)\$(OutDir)" /Y

but copying them by hand should also do the trick.但是手工复制它们也应该可以解决问题。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么无法删除System.Drawing并替换为NuGet包System.Drawing.Common - Why unable to remove System.Drawing and replace with NuGet package System.Drawing.Common 在 AWS Lambda 上使用 System.Drawing.Common NuGet 包时无法加载 DLL“libdl” - Unable to load DLL 'libdl' when using System.Drawing.Common NuGet package on AWS Lambda IronPDF 对 System.Drawing.Common 的依赖 - IronPDF dependency on System.Drawing.Common System.Drawing.Common 不适用于 Windows - System.Drawing.Common not working on Windows 如何在使用“.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'? .NET Core System.Drawing.Common PrintDocument在Linux上不起作用 - .NET Core System.Drawing.Common PrintDocument doesn't work on Linux 使用 C#.net5.0 但没有 System.Drawing.Common 获取/设置图像文件的分辨率? - Get/set the resolution of an image file using C# net5.0 but without System.Drawing.Common? 错误 NU1100:无法为“net6.0”解析“HtmlAgilityPack (&gt;= 1.11.45)”和“System.Drawing.Common (&gt;= 6.0.0)” - error NU1100: Unable to resolve 'HtmlAgilityPack (>= 1.11.45)' and 'System.Drawing.Common (>= 6.0.0)' for 'net6.0' .NET 6/7 从 System.Drawing.Common 迁移到 Microsoft.Maui.Graphics - .NET 6/7 Migration from System.Drawing.Common to Microsoft.Maui.Graphics 无法在 DLL 的类中加载依赖项 system.drawing.common - Cannot load dependency system.drawing.common in a class in a DLL
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM