I was trying to add System.Drawing library inside a lambda function using container image. Followed the AWS documentation here
Added
RUN yum install -y amazon-linux-extras
RUN amazon-linux-extras install epel -y
RUN yum install -y libgdiplus
Inside the Dockerfile
.
while calling the lambda i am getting an error
System.TypeInitializationException: The type initializer for 'Gdip' threw an exception. System.PlatformNotSupportedException: System.Drawing.Common is not supported on non-Windows platforms. See https://aka.ms/systemdrawingnonwindows for more information.
CodePudding user response:
The issue was with the version of System.Drawing.Common package I am using. I've downgraded the package from 6.0.0 to 4.7.0 and the error went away.
CodePudding user response:
You don't need to downgrade the package from v6.0.0. In .NET 6 you can fix the issue by adding this line to your startup code (before calling any GDI-dependent code):
AppContext.SetSwitch("System.Drawing.EnableUnixSupport", true);
But please note that this will not work in v7.0.0 and above. Unix support has already been removed from the 7.0.0-preview.* versions.