Closed laurentAstonIf closed 1 year ago
Hi i have actually solved this problem using AppContext.SetSwitch("System.Drawing.EnableUnixSupport", true); in the startup of the azure function
Hi @pragnagopa could you please look into this issue?
Hi @laurentAstonIf Can we close it as resolved? or you still need anything from us?
My workaround is working so you can close it Thanks
@laurentAstonIf Thanks.
Hi
I'm migrating from AF V3/ Core 3.1 to AF V4 / Net 6.0
(hosted on Function App with linux plan)
Some of my functions use external components that still use System.Drawing.Common which make these functions crash with "System.Drawing.Common: The type initializer for 'Gdip' threw an exception. System.Drawing.Common: System.Drawing.Common is not supported on non-Windows platforms"
I have added in my function project file
<GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
and within the main directory runtimeconfig.template.json with content{ "configProperties": { "System.Drawing.EnableUnixSupport": true } }
this is the content of MyFunction.runtimeconfig.json which is generated
{ "runtimeOptions": { "tfm": "net6.0", "framework": { "name": "Microsoft.NETCore.App", "version": "6.0.0" }, "configProperties": { "System.Drawing.EnableUnixSupport": true } } }
Running the function still produce :not supported on non-Windows platforms
if i set the property GenerateRuntimeConfigurationFiles to false i have warnings at build time
warning CA1416: This call site is reachable on all platforms. 'Image.Width' is only supported on: 'windows'
=> i can understand that it will crashbut if the param is set to true, then i have no warning which make me thought that the parameter + runtimeconfig.template.json was understood/manage
The same process has been applied to an asp net.core webapp hosted on the same plan and it works
Am I missing something or it's a bug ?
i have created a simple function under wsl2 with func new --template "Http Trigger" --name MyDrawingHttpTrigger and add a call to Bitmap => this project is included in the sample.zip
Regards Laurent dotnet --version : 6.0.300 Microsoft.NET.Sdk.Functions : 4.1.0 sample.zip