Skip to content

DllNotFoundException on MAUI net8.0-android #1818

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
alexey-leonovich opened this issue Apr 2, 2025 · 6 comments
Open

DllNotFoundException on MAUI net8.0-android #1818

alexey-leonovich opened this issue Apr 2, 2025 · 6 comments

Comments

@alexey-leonovich
Copy link

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

@dlemstra
Copy link
Owner

dlemstra commented Apr 2, 2025

As mentioned in #22 there is no support for running this library on android.

@alexey-leonovich
Copy link
Author

alexey-leonovich commented Apr 2, 2025

Is that because there is no official build of native Magick library for this OS? There is an unofficial Android build which is synced to main repo.

@dlemstra
Copy link
Owner

dlemstra commented Apr 2, 2025

That is not a build of the Magick.Native library but a custom build of ImageMagick.

@alexey-leonovich
Copy link
Author

I got you point. Just curious: there is a technical limitation to make an Android version of the Magick.Native library or it's just a lack of time?

@dlemstra
Copy link
Owner

dlemstra commented Apr 2, 2025

Maybe both? I haven't invested any time in making the build work on android or ios.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants
@dlemstra @alexey-leonovich and others