dotnet / dotnet/smartcomponents

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

Open
#45 4 comments 2 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
508
Forks
61
PR merge metrics
No merged PRs in 30d

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](https://github.com/user-attachments/files/22464601/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

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.