Azure函数给出错误:此平台不支持System.Drawing

编程入门 行业动态 更新时间:2024-10-24 22:17:52
本文介绍了Azure函数给出错误:此平台不支持System.Drawing的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

(如果这个问题的措词不好,有人可以帮我解决吗?)

(If this question is poorly worded, could someone please help me clear it up?)

我有一个依靠某些系统的Azure功能(2.0)。绘图代码。我添加了对System.Drawing.Common(4.5.0)的NuGet引用。

I have an Azure Function (2.0) which relies on some System.Drawing code. I've added a NuGet reference to System.Drawing.Common (4.5.0).

发布应用程序后,但是,在调用该函数时,它会产生错误:

After publishing the app, however, when the function is called, it produces the error:

System.Private.CoreLib:执行函数时异常: [MyFunctionName]。 System.Drawing.Common:该平台不支持。

System.Private.CoreLib: Exception while executing function: [MyFunctionName]. System.Drawing.Common: System.Drawing is not supported on this platform.

据我所知,.NET Core现在支持System.Drawing.Common,我认为这是运行Azure函数的环境。但是,实际的项目是.NET Standard 2.0项目。

As far as I'm aware, System.Drawing.Common is supported on .NET Core now, which I believe is the environment in which my Azure Function is running. The actual project is a .NET Standard 2.0 project, though.

我对如何解决此问题感到困惑。我尝试将项目转换为.NET Core 2.1项目,但是导致了与元数据生成失败有关的奇怪错误,并且无法找到System.Runtime。

I am confused as to how to resolve this. I've tried converting the project to a .NET Core 2.1 project but that led to bizarre errors related to "Metadata generation failed" and an inability to find System.Runtime.

我的项目引用了Microsoft.Azure.WebJobs.Extensions.EventGrid(2.0.0-beta2)(如果相关)。

My project references Microsoft.Azure.WebJobs.Extensions.EventGrid (2.0.0-beta2) if that's relevant.

推荐答案

与CLR无关,与沙盒。

System.Drawing在很大程度上依赖于GDI / GDI +。由于这些API的风险性质(攻击面较大),它们在App Service沙箱中受到限制。

System.Drawing relies heavily on GDI/GDI+ to do its thing. Because of the somewhat risky nature of those APIs (large attack surface) they are restricted in the App Service sandbox.

Win32k.sys(User32 / GDI32)限制

为了减少攻击的表面积,沙箱阻止了几乎所有Win32k.sys API的调用,这实际上意味着大部分User32 / GDI32系统调用均被阻止。对于大多数应用程序而言,这不是问题,因为大多数Azure Web Apps不需要访问Windows UI功能(毕竟它们是Web应用程序)。 Win32k.sys (User32/GDI32) Restrictions

For the sake of radical attack surface area reduction, the sandbox prevents almost all of the Win32k.sys APIs from being called, which practically means that most of User32/GDI32 system calls are blocked. For most applications this is not an issue since most Azure Web Apps do not require access to Windows UI functionality (they are web applications after all).

尝试查找不依赖System.Drawing / GDI的其他库,例如 ImageSharp 。

Try to find an different library that doesn't rely on System.Drawing/GDI, like ImageSharp.

更多推荐

Azure函数给出错误:此平台不支持System.Drawing

本文发布于:2023-11-14 15:26:30,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1587832.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不支持   函数   错误   平台   Azure

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!