Exception has occurred: CLR/System.TypeInitializationException
An exception of type 'System.TypeInitializationException' occurred in OpenCvSharp.dll but was not handled in user code: 'The type initializer for 'OpenCvSharp.Internal.NativeMethods' threw an exception.'
Inner exceptions found, see $exception in variables window for more details.
Innermost exception System.DllNotFoundException : Unable to load shared library 'OpenCvSharpExtern' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:
/opt/dotnet/shared/Microsoft.NETCore.App/8.0.6/OpenCvSharpExtern.so: cannot open shared object file: No such file or directory
/opt/dotnet/shared/Microsoft.NETCore.App/8.0.6/libOpenCvSharpExtern.so: cannot open shared object file: No such file or directory
/opt/dotnet/shared/Microsoft.NETCore.App/8.0.6/OpenCvSharpExtern: cannot open shared object file: No such file or directory
/opt/dotnet/shared/Microsoft.NETCore.App/8.0.6/libOpenCvSharpExtern: cannot open shared object file: No such file or directory
at OpenCvSharp.Internal.NativeMethods.redirectError(CvErrorCallback errCallback, IntPtr userdata, IntPtr& prevUserdata)
at OpenCvSharp.Internal.ExceptionHandler.RegisterExceptionCallback()
at OpenCvSharp.Internal.NativeMethods.LoadLibraries(IEnumerable`1 additionalPaths)
at OpenCvSharp.Internal.NativeMethods..cctor()
.NET SDK:
Version: 8.0.302
Commit: ef14e02af8
Workload version: 8.0.300-manifests.f6879a9a
MSBuild version: 17.10.4+10fbfbf2e
Runtime Environment:
OS Name: debian
OS Version: 12
OS Platform: Linux
RID: linux-arm64
Base Path: /opt/dotnet/sdk/8.0.302/
.NET workloads installed:
There are no installed workloads to display.
Host:
Version: 8.0.6
Architecture: arm64
Commit: 3b8b000a0e
.NET SDKs installed:
8.0.302 [/opt/dotnet/sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 8.0.6 [/opt/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 8.0.6 [/opt/dotnet/shared/Microsoft.NETCore.App]
Other architectures found:
None
Environment variables:
DOTNET_ROOT [/opt/dotnet]
global.json file:
Not found
Learn more:
https://aka.ms/dotnet/info
Download .NET:
https://aka.ms/dotnet/download
What did you do when you faced the problem?
Write here
Example code:
using var image = Cv2.ImRead(file.FullName);
Output:
Exception has occurred: CLR/System.TypeInitializationException
An exception of type 'System.TypeInitializationException' occurred in OpenCvSharp.dll but was not handled in user code: 'The type initializer for 'OpenCvSharp.Internal.NativeMethods' threw an exception.'
Inner exceptions found, see $exception in variables window for more details.
Innermost exception System.DllNotFoundException : Unable to load shared library 'OpenCvSharpExtern' or one of its dependencies. In order to help diagnose loading problems, consider using a tool like strace. If you're using glibc, consider setting the LD_DEBUG environment variable:
/opt/dotnet/shared/Microsoft.NETCore.App/8.0.6/OpenCvSharpExtern.so: cannot open shared object file: No such file or directory
/opt/dotnet/shared/Microsoft.NETCore.App/8.0.6/libOpenCvSharpExtern.so: cannot open shared object file: No such file or directory
/opt/dotnet/shared/Microsoft.NETCore.App/8.0.6/OpenCvSharpExtern: cannot open shared object file: No such file or directory
/opt/dotnet/shared/Microsoft.NETCore.App/8.0.6/libOpenCvSharpExtern: cannot open shared object file: No such file or directory
at OpenCvSharp.Internal.NativeMethods.redirectError(CvErrorCallback errCallback, IntPtr userdata, IntPtr& prevUserdata)
at OpenCvSharp.Internal.ExceptionHandler.RegisterExceptionCallback()
at OpenCvSharp.Internal.NativeMethods.LoadLibraries(IEnumerable`1 additionalPaths)
at OpenCvSharp.Internal.NativeMethods..cctor()
I found out the linux-arm64 native file is missing and the arm nuget package does not have it.
I think a good solution for this problem is adding a linux-arm64 nuget package.
Summary of your issue
I got this error on linux-arm64 raspberry pi
Environment
What did you do when you faced the problem?
Write here
Example code:
Output:
What did you intend to be?
read a file