[英]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。
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.