System.TypeInitializationException: The type initializer for 'Gdip' threw an exception


Question: Has anyone found the fix for this issue yet? "

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.
   at System.Drawing.LibraryResolver.EnsureRegistered()
   at System.Drawing.SafeNativeMethods.Gdip.PlatformInitialize()
   at System.Drawing.SafeNativeMethods.Gdip..cctor()


Login to See the Rest of the Answer

Answer: If you are looking to generate images on Linux using C# or Asp.Net 6 inside a Docker Container, do not use any libraries. The libraries available online do not work (at least for me). The easiest way to generate Images on Linux using C# or Asp.Net Core is by using Stream.

Steps:

1. Read an Image as a Stream
    This can be accomplished by using System.IO.File.Read() or just Load the bytes from the 
    Binary Base64 String.

2. Use the "using directive" that allows you to clean up after completing using the Stream. 

3. Finally, using the SourceOfTheOriginalStream.CopyToAsync(""urlPath);
    and you are done.

4. If you happen to be in need of modifying the Image settings, then you might be out of luck doing that on Linux. You would need to use the Windows Server or some sort to accomplish that task.









For peering opportunity Autonomouse System Number: AS401345 Custom Software Development at ErnesTech Email Address[email protected]