Skip to content

DllNotFoundException on MAUI net8.0-android #1818

@alexey-leonovich

Description

@alexey-leonovich

Magick.NET version

Magick.NET-Q8-AnyCPU 14.6.0

Environment (Operating system, version and so on)

Windows 10 x64 22H2 + Android Emulator (default virtual device - Pixel 7 API 35) + VS 2022 17.13.5

Description

I've created a netstandard20 class library and added Magick.NET-Q8-AnyCPU 14.6.0 nuget reference to it. In it I simply open image via:
using var image = new MagickImage(new FileInfo(imagePath));
And I've created MAUI application from a template (.NET 8.0 framework), referenced my class library and called that method. And i got an exception:

{System.TypeInitializationException: The type initializer for 'NativeMagickSettings' threw an exception.
 ---> System.DllNotFoundException: Magick.Native-Q8-x64.dll
   at ImageMagick.Environment.NativeMethods.Environment_Initialize() in /_/src/Magick.NET/Generated/Magick.NET.SourceGenerator/ImageMagick.SourceGenerator.NativeInteropGenerator/Environment.g.cs:line 56
   at ImageMagick.Environment.NativeEnvironment.Initialize() in /_/src/Magick.NET/Generated/Magick.NET.SourceGenerator/ImageMagick.SourceGenerator.NativeInteropGenerator/Environment.g.cs:line 90
   at ImageMagick.Environment.Initialize() in /_/src/Magick.NET/Helpers/Environment.cs:line 21
   at ImageMagick.MagickSettings.NativeMagickSettings..cctor() in /_/src/Magick.NET/Generated/Magick.NET.SourceGenerator/ImageMagick.SourceGenerator.NativeInteropGenerator/MagickSettings.g.cs:line 737
   --- End of inner exception stack trace ---
   at ImageMagick.MagickSettings..ctor() in /_/src/Magick.NET/Settings/MagickSettings.cs:line 33
   at ImageMagick.MagickImage..ctor() in /_/src/Magick.NET/MagickImage.cs:line 43
   at ImageMagick.MagickImage..ctor(FileInfo file) in /_/src/Magick.NET/MagickImage.cs:line 117
   at CrossPlatformUtils.Graphics.ResizeImage(String sourcePath, UInt32 resizedWidth, UInt32 resizedHeight) in D:\projects\Resto.CrossPlatformUtils\Graphics.cs:line 13}

Running same MAUI application on Windows (net8.0-windows10.0.19041.0 target) is ok. Looks like it's Android specific.

Steps to Reproduce

  1. Create a netstandard20 class library
  2. Add Magick.NET-Q8-AnyCPU 14.6.0 nuget reference
  3. Create Graphics.cs with Graphics class and TestMagick function that calls using var image = new MagickImage(new FileInfo(imagePath));
  4. Create MAUI application (chose .NET8.0 framework)
  5. Refefence the class library in the MAUI application
  6. Add a call of Graphics.TestMagick function
  7. Start debugging on Android Emulator (default virtual device - Pixel 7 API 35)

Images

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions