Skip to content

Microsoft.ML.OnnxRuntime.NativeMethods Exception in Blazor MAUI Mac Catalyst #45

@AbishekRoyDennisRaj

Description

@AbishekRoyDennisRaj

Description

When a .NET MAUI Blazor application includes the SmartComponents.LocalEmbeddings and Microsoft.ML.OnnxRuntime, the project throws an exception in intialization phase of LocalEmbedder localEmbedder = new LocalEmbedder(); in Mac Catalyst framework.

Have also tried placing the libonnxruntime.dylib in monobundle folder manually but still facing the mentioned exception. The version used for Microsoft.ML.OnnxRuntime is 1.22.1.

Image

Steps to Reproduce:

  1. Create a new .NET MAUI Blazor project.
  2. Add the SmartComponents.LocalEmbeddings and Microsoft.ML.OnnxRuntime NuGet package.
  3. Set the target to net8.0-ios or net8.0-maccatalyst.
  4. Create a onclick function in which initialze LocalEmbedder().
  5. Exception is getting thrown.

or

  1. Download the attached .NET MAUI Blazor project. BlazorMAUI.zip
  2. Run the sample.
  3. Click the Initialize Local Embeddings button
  4. Exception is getting thrown.

Expected Behavior:

During OnClick Event the initialization of LocalEmbedder() should take place correctly

Actual Behavior:

Initialization fails on Mac Catalyst throwing exception of The type initializer for "Microsoft.ML.OnnxRuntime.NativeMethods" threw an exception

Environment:

  • .NET SDK: 8.0.203
  • MAUI Version: 8.0.x
  • macOS: macOS Sequoia 15.6
  • Target Frameworks: net8.0-ios, net8.0-maccatalyst
  • Device: Simulator and Physical Device
  • SmartComponents.LocalEmbeddings Version: 0.1.0-preview10148
  • Microsoft.ML.OnnxRuntime Version: 1.22.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions