Azure函数给出错误:此平台不支持System.Drawing [英] Azure Function gives error: System.Drawing is not supported on this platform

查看:150
本文介绍了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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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