dlemstra / Magick.NET

The .NET library for ImageMagick
Apache License 2.0
3.45k stars 415 forks source link

DllNotFoundException on MAUI maccatalyst #1506

Open nathenxbrewer opened 9 months ago

nathenxbrewer commented 9 months ago

Magick.NET version

13.5.0 Magick.NET.Core and Magick.NET-Q16-x64

Environment (Operating system, version and so on)

MAUI maccatalyst

Description

I'm getting a DllNotFoundException when running on maccatalyst using .NET MAUI. This package was working fine for my console app. I wrote a GUI using MAUI and now I'm getting this error. I tried to copy the osx-x64 folder containing the Magick lib into my MAUI bin folder but that did not work. It seems maybe maccatalyst-x64 is not supported?

Steps to Reproduce

Create .NET MAUI application. Install Magick.NET Run on MacCatalyst

dlemstra commented 9 months ago

I don't have a mac so I cannot test this myself. I suspect that you will need to copy the content of the osx-64 folder in your bin folder to make this work. It might also be possible that you need that arm64 version instead.

nathenxbrewer commented 9 months ago

I don't have a mac so I cannot test this myself. I suspect that you will need to copy the content of the osx-64 folder in your bin folder to make this work. It might also be possible that you need that arm64 version instead.

I tried copying the osx-64 files over and that didn't change anything. I'll give the arm folder a shot. To clarify, where should this folder reside in a MAUI project?

dlemstra commented 9 months ago

The native file should be in the bin folder of your project that also contains the Magick.NET library.

nathenxbrewer commented 2 months ago

System.DllNotFoundException: Magick.Native-Q16-arm64.dll at ImageMagick.Environment.NativeEnvironment.Initialize() in //src/Magick.NET/Generated/Magick.NET.SourceGenerator/ImageMagick.SourceGenerator.NativeInteropGenerator/Environment.g.cs:line 56 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 299

Still getting this error. I've put the .dll's in my bin folder as suggested.

Project/bin/Debug/net8.0-maccatalyst/maccatalyst-arm64/Magick.Native-Q16-arm64.dll

This is the only library I can find to edit my images and convert color profiles. I have a console app working just fine but I need a full GUI. Any suggestions on how to get this to work on .NET MAUI?

nathenxbrewer commented 2 months ago

https://github.com/dlemstra/Magick.NET/issues/22#issuecomment-600029537

This seems to do the trick..but I cannot figure out how to get this to copy in when building the project so currently the IDE is throwing error about unexpected files in the .app contents. So I have to manually copy each time I debug/build. I've tried

    <Content Include="Magick\osx-arm64\Magick.Native-Q16-arm64.dll" >
        <TargetPath>Contents\MonoBundle\Magick.Native-Q16-arm64.dll</TargetPath>
        <CopyToPublishDirectory>Always</CopyToPublishDirectory>
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </Content>    

    as well as 

     <MauiAsset Include="Magick\osx-arm64\Magick.Native-Q16-arm64.dll" >
        <TargetPath>Contents\MonoBundle\Magick.Native-Q16-arm64.dll</TargetPath>
        <CopyToPublishDirectory>Always</CopyToPublishDirectory>
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
    </MauiAsset >