GroupDocs.Conversion not working on linux with .NET 8

Groupdocs.Conversion worked well with .NET 6 on docker linux. Since the upgrade to .NET 8, we receive “System.PlatformNotSupportedException : System.Drawing.Common is not supported on non-Windows platforms”.

System.Drawing.EnableUnixSupport trick is not supported anymore by microsoft since .NET 7 : Breaking change: System.Drawing.Common config switch removed - .NET | Microsoft Learn

Can you tell me if Groupdocs.Conversion support .NET 8 on linux container?

GroupDocs.Conversion.Exceptions.GroupDocsConversionException: The type initializer for ‘Gdip’ threw an exception.\n —> System.TypeInitializationException: The type initializer for ‘Gdip’ threw an exception.\n —> System.PlatformNotSupportedException: System.Drawing.Common is not supported on non-Windows platforms. See Breaking change: System.Drawing.Common only supported on Windows - .NET | Microsoft Learn for more information.\n at System.Drawing.SafeNativeMethods.Gdip.<>c.<.cctor>b__2_0(String _, Assembly _, Nullable`1 _)\n at System.Runtime.InteropServices.NativeLibrary.LoadLibraryCallbackStub(String libraryName, Assembly assembly, Boolean hasDllImportSearchPathFlags, UInt32 dllImportSearchPathFlags)\n at System.Drawing.SafeNativeMethods.Gdip.g____PInvoke|32_0(IntPtr* __token_native, StartupInputEx* __input_native, StartupOutput* __output_native)\n at System.Drawing.SafeNativeMethods.Gdip.GdiplusStartup(IntPtr& token, StartupInputEx& input, StartupOutput& output)\n at System.Drawing.SafeNativeMethods.Gdip…cctor()\n — End of inner exception stack trace —\n — End of inner exception stack trace —\n at bool \u0006\u0002\u001a+\u0002.\u0002(Exception \u0002)\n at void AggregateException.Handle(Func<Exception, bool> predicate)\n at void \u0006\u0002\u001a.\u0002(CancellationToken \u0002)\n at void GroupDocs.Conversion.Converter.\u0002(CancellationToken \u0002)\n at void GroupDocs.Conversion.Converter.Convert(Func document, Action<string, FileType, Stream> documentCompleted, Func<string, FileType, ConvertOptions> convertOptionsProvider, CancellationToken cancellationToken)\n

@frederic.geslin

For .NET 8 please use GroupDocs.Conversion.CrossPlatform package. This package uses cross-platform Aspose graphical library instead of System.Drawing.Common which is not supported on Linux.

Unfortunately we already use this package and the problem is still there…

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>net8.0</TargetFramework>
    <Nullable>disable</Nullable>
    <ImplicitUsings>disable</ImplicitUsings>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
  </PropertyGroup>

  <ItemGroup>
    <EmbeddedResource Include="GroupDocs.Conversion.NET.lic" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Aspose.3D" Version="24.11.0" />
    <PackageReference Include="Aspose.CAD" Version="24.11.0" />
    <PackageReference Include="Aspose.Cells" Version="24.12.0" />
    <PackageReference Include="Aspose.Diagram" Version="24.12.0" />
    <PackageReference Include="Aspose.Email" Version="24.11.0" />
    <PackageReference Include="Aspose.Finance" Version="24.12.0" />
    <PackageReference Include="Aspose.Font" Version="24.11.0" />
    <PackageReference Include="Aspose.GIS" Version="24.11.0" />
    <PackageReference Include="Aspose.HTML" Version="24.11.0" />
    <PackageReference Include="Aspose.Imaging" Version="24.12.0" />
    <PackageReference Include="Aspose.Note" Version="24.11.0" />
    <PackageReference Include="Aspose.PDF" Version="24.12.0" />
    <PackageReference Include="Aspose.PSD" Version="24.12.0" />
    <PackageReference Include="Aspose.PUB" Version="24.10.0" />
    <PackageReference Include="Aspose.Slides.NET6.CrossPlatform" Version="24.12.0" />
    <PackageReference Include="Aspose.SVG" Version="24.11.0" />
    <PackageReference Include="Aspose.SVG.Drawing.SkiaSharp" Version="24.11.0" />
    <PackageReference Include="Aspose.Tasks" Version="24.12.0" />
    <PackageReference Include="Aspose.Words" Version="24.12.0" />
    <PackageReference Include="Aspose.Zip" Version="24.12.0" />
    <PackageReference Include="GroupDocs.Conversion.CrossPlatform" Version="24.11.0" />
  </ItemGroup>

@frederic.geslin

May you please share a Dockerfile with sample code and the file so we could reproduce and analyze this issue?

We manage to make it work by removing the following references from the main csproj, Thank you

   <PackageReference Include="Aspose.3D" Version="24.8.0" />
    <PackageReference Include="Aspose.CAD" Version="24.8.0" />
    <PackageReference Include="Aspose.Cells" Version="24.9.0" />
    <PackageReference Include="Aspose.Diagram" Version="24.9.0" />
    <PackageReference Include="Aspose.Email" Version="24.8.0" />
    <PackageReference Include="Aspose.Finance" Version="24.8.0" />
    <PackageReference Include="Aspose.Font" Version="24.9.0" />
    <PackageReference Include="Aspose.GIS" Version="24.8.0" />
    <PackageReference Include="Aspose.HTML" Version="24.8.0" />
    <PackageReference Include="Aspose.Imaging" Version="24.9.0" />
    <PackageReference Include="Aspose.Note" Version="24.8.0" />
    <PackageReference Include="Aspose.PDF" Version="24.9.0" />
    <PackageReference Include="Aspose.PSD" Version="24.8.0" />
    <PackageReference Include="Aspose.PUB" Version="24.8.0" />
    <PackageReference Include="Aspose.Slides.NET6.CrossPlatform" Version="24.9.0" />
    <PackageReference Include="Aspose.SVG" Version="24.8.0" />
    <PackageReference Include="Aspose.SVG.Drawing.SkiaSharp" Version="24.8.0" />
    <PackageReference Include="Aspose.Tasks" Version="24.8.0" />
    <PackageReference Include="Aspose.Words" Version="24.9.0" />
    <PackageReference Include="Aspose.Zip" Version="24.8.0" />

@frederic.geslin

I’m glad the issue has been resolved.

Please let us know if you have any further questions.