Skip to content

DllNotFoundException OpenCvSharpExtern when running .NET MAUI on MacOS #1721

@LoooooKe

Description

@LoooooKe

Summary of your issue

DllNotFoundException OpenCvSharpExtern when running .NET MAUI on MacOS 15.1. If I run a simple App with Avalonia instead of MAUI everything works as intended.

I tracked the issue to

When ruuning MAUI on MacOS, IsUnix() returns False because MacCatalyst is not in the list on L188.

It should be an easy fix to add MacCatalyst to this List.

Environment

  • MacOS Sequoia 15.1, XCode 16.1
  • .NET 9
  • MAUI 9.0.0
  • OpenCvSharp4 4.10.20241108
  • OpenCvSharp4.runtime.osx_arm64 4.8.1-rc

What did you do when you faced the problem?

Generate simple MAUI App by Rider, install OpenCvSharp & osx.runtime. Somewhere initialize OpenCv (eg. VideoCapture.FromCamera). Exception occurs during initialization of OpenCvSharp.

Example code:

Console.WriteLine($"IsOSX: {RuntimeInformation.IsOSPlatform(OSPlatform.OSX)}");
Console.WriteLine($"IsMacCatalyst: {System.OperatingSystem.IsMacCatalyst()}");
Console.WriteLine($"IsLinux: {System.OperatingSystem.IsLinux()}");
cap = VideoCapture.FromCamera(0);
if(cap.IsOpened())
    Console.Out.WriteLine("Cap is opened");

Output:

2024-11-17 22:45:27.548 MauiTest[34843:374890] IsOSX: False
2024-11-17 22:45:27.548 MauiTest[34843:374890] IsMacCatalyst: True
2024-11-17 22:45:27.548 MauiTest[34843:374890] IsLinux: False

What did you intend to be?

App and VideoCapture should start without any Exceptions.

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