Skip to content
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

DllNotFoundException on MAUI maccatalyst #1506

Open
nathenxbrewer opened this issue Jan 4, 2024 · 5 comments
Open

DllNotFoundException on MAUI maccatalyst #1506

nathenxbrewer opened this issue Jan 4, 2024 · 5 comments

Comments

@nathenxbrewer
Copy link

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
Copy link
Owner

dlemstra commented Jan 5, 2024

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
Copy link
Author

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
Copy link
Owner

dlemstra commented Jan 5, 2024

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

@nathenxbrewer
Copy link
Author

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
Copy link
Author

#22 (comment)

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 >    

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

2 participants