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

Open
#45 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Quiet
Tech stack
csharp
Domain
mobile-dev

Research direction

Start with the attached BlazorMAUI.zip sample and reproduce the failure by targeting net8.0-maccatalyst or net8.0-ios and clicking the Initialize Local Embeddings button. Trace the LocalEmbedder() initialization through Microsoft.ML.OnnxRuntime.NativeMethods and verify that it completes without the type-initializer exception on the reported simulator and device environments.

Written by the indexing model from the issue text.

Description

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
Dominant language
C#
Stars
509
Forks
61
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from dotnet/smartcomponents

All issues in dotnet/smartcomponents

Similar issues

More C# issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.