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

'Microsoft.ML.OnnxRuntime.NativeMethods' threw an exception #23300

Open
Sriharsha-medevplus opened this issue Jan 9, 2025 · 3 comments
Open
Labels
api:CSharp issues related to the C# API .NET Pull requests that update .net code stale issues that have not been addressed in a while; categorized by a bot

Comments

@Sriharsha-medevplus
Copy link

Sriharsha-medevplus commented Jan 9, 2025

Describe the issue

I have installed OnnxRuntime for C# using the NuGet package manager, it is working fine with my device.
but when I try to install the .net application with the model in other PC's I get: error loading image: The type initializer for 'Microsoft.ML.OnnxRuntime.NativeMethods' threw an exception.

Object reference not set to an instance of an object.
at Microsoft.ML.OnnxRuntime.NativeMethods..cctor() in D:\a_work\1\s\csharp\src\Microsoft.ML.OnnxRuntime\NativeMethods.shared.cs:line 368

To reproduce

Image

Urgency

No response

Platform

Windows

OS Version

11/ 10

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

1.20.1

ONNX Runtime API

C#

Architecture

X64

Execution Provider

Default CPU

Execution Provider Library Version

No response

@github-actions github-actions bot added .NET Pull requests that update .net code api:CSharp issues related to the C# API labels Jan 9, 2025
@skottmckay
Copy link
Contributor

Usually that's due to a dependency like the onnxruntime.dll not being found.

https://learn.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#standard-search-order-for-unpackaged-apps

@Sriharsha-medevplus
Copy link
Author

Hi @skottmckay, I've tried using the setdlldirectory and checked the process explorer, found the onnxruntime.dll being loaded from the bin folder but when I try to deploy the app in other PC this issue is persistent there. Is there any other fix for this?

Copy link
Contributor

github-actions bot commented Feb 9, 2025

This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details.

@github-actions github-actions bot added the stale issues that have not been addressed in a while; categorized by a bot label Feb 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api:CSharp issues related to the C# API .NET Pull requests that update .net code stale issues that have not been addressed in a while; categorized by a bot
Projects
None yet
Development

No branches or pull requests

2 participants