gpt4 book ai didi

asp.net-core - 如何在 Asp.Net Core 3 中访问 System.Drawing 即 System.Drawing.Common

转载 作者:行者123 更新时间:2023-12-03 15:28:00 30 4
gpt4 key购买 nike

我正在将面向完整框架的 Asp.Net Core 2.2 网站转换为面向 .Net Core 3.1 的 Asp.Net Core 3.1 应用程序。我有点不清楚与 System.Drawing 相关的依赖关系以及如何实现它们。

我的项目使用 System.Drawing,在 Asp.Net Core 3.1 下编译时出现此错误,提示我添加了对 System.Drawing.Common.dll 的引用。 :

Error CS1069: The type name 'Image' could not be found in the namespace 'System.Drawing'. This type has been forwarded to assembly 'System.Drawing.Common, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly. 1-wwwGiftOasis3 C:\Users\Ron\source\repos\wwwGiftOasis3\wwwGiftOasis3\site\seller\profile\about\s-photos.cs



在 Visual Studio 中,我没有看到直接向裸 System.Drawing.Common.dll 添加引用的方法所以我假设我应该通过 NuGet 添加引用。

在 NuGet 中,我看到一个 System.Drawing.Common看起来像我想要的包,但我不清楚我的项目是否满足依赖项:

enter image description here

我的项目显示了这些依赖项:

enter image description here

所以我有几个与这一切相关的问题:

1) 我的项目是否依赖于框架 Microsoft.NETCore.App完成 NuGet 包的 Microsoft.NETCore.Platforms依赖?

2) 我打算只在 Windows 上运行这个 Asp.Net Core 3.1 网站这一事实是否符合 NuGet 包的 Microsoft.Win32.SystemEvents依赖?

最佳答案

System.Drawing使用特定于 Windows 的 API,因此与跨平台的 .NET Core 不兼容。微软创建 System.Drawing.Common作为 System.Drawing 的就地替代品对于 .NET 核心。它是一个精确的 API 替代品,但以跨平台的方式执行图像操作,而不是特定于 Windows 的方式。

总而言之,是的,您只需将 NuGet 放入您的项目中,然后前往镇上即可。您无需担心其他任何事情。

关于asp.net-core - 如何在 Asp.Net Core 3 中访问 System.Drawing 即 System.Drawing.Common,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59324386/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com