shimat / opencvsharp

OpenCV wrapper for .NET
Apache License 2.0
5.22k stars 1.13k forks source link

Unable to load DLL 'OpenCvSharpExtern' or one of its dependencies #1664

Open NonicaTeam opened 2 months ago

NonicaTeam commented 2 months ago

Summary of your issue

Environment

Net8.0

What did you do when you faced the problem?

Migrate Opencvsharp4.0 from net framework to net8.0 using visual studio migration. As it was raising the issue, I uninstall and reinstall different versions but I am unable to get it working. I have OpenCVSharp4 and OpenCVSharp4.runtime.win installed and built in my output directory. I also tried to copy the runtimes (opencv_videoio_ffmpeg490_64.dll, OpenCvSharpExtern.dll) next to the main OpenCvSharp.dll but it did not work either. I have tried soo many solutions online but could not get it working. Taget framework is x64 and those dll were copied next to main dll. I also added System.memory and system.compiler.unsafe next to it.

Example code:

var edgedetection = Cv2.ImRead(init_hdlr_image);

Output:

DllNotFoundException: Unable to load DLL 'OpenCvSharpExtern' or one of its dependencies: The specified module could not be found. (0x8007007E)
System.TypeInitializationException: 'The type initializer for 'OpenCvSharp.Internal.NativeMethods' threw an exception.'

What did you intend to be?

No error and loading properly

AvenSun commented 1 month ago

It looks like some dll missing, you can check this first.