32

i'm trying to debug my program, using emgu and HaarCascade in c#. i'm getting an exception like so :

Unable to load DLL 'cvextern': The specified module could not be found. (Exception from HRESULT: 0x8007007E)

i've added the file cvextern.dll to my project and tried both "copy always" and "copy if newer" options on the properties of the file. also, the build is in platform x64.

here's partly what i wrote :

    private void Load_Click(object sender, EventArgs e)
    {
        OpenFileDialog dlg = new OpenFileDialog();
        dlg.Filter = "Photo Files (*.jpg)|*.JPG";
        dlg.CheckFileExists = true;
        if (dlg.ShowDialog() == DialogResult.OK)
        {
            Image<Bgr, Byte> My_Image = new Image<Bgr, byte>(dlg.FileName);
            HaarCascade face = new HaarCascade("haarcascade_frontalface_alt.xml");

and the exception is in the last line.

BenMorel
  • 34,448
  • 50
  • 182
  • 322
dusm
  • 1,207
  • 4
  • 18
  • 24

11 Answers11

22

Just Install : this nuget package

Because there are some unmanaged code and you have to add those references on your project

See the ChangeLog

Ali Besharati
  • 918
  • 12
  • 25
  • 1
    This is not possible on a .NET project. `Severity Code Description Project File Line Suppression State Error Could not install package 'Emgu.runtime.windows.msvc.rt.arm64 19.33.31630'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.7.2', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. ` – Seth Feb 19 '23 at 06:40
  • @Seth you should choose the correct version or downgrade your target framework – Ali Besharati Feb 25 '23 at 15:12
  • 1
    There is no other version than the one specified. I can't downgrade the target framework. I simply wrote it in python instead and call the python from my C# program with arguments – Seth Feb 28 '23 at 04:07
  • i replace "windows" with "ubuntu" everythings works fine – ehsan wwe Aug 13 '23 at 05:47
21

The error your receiving is not solely down to cvextern this dll actually points to almost all of the other opencv dlls and all are required. With this error you will require the following dll in your project.

Note that the "220" is the version number this will change according to updates.

  • cudart64_32_16.dll
  • cufft64_32_16.dll
  • cvextern.dll
  • npp64_32_16.dll
  • opencv_calib3d220.dll
  • opencv_contrib220.dll
  • opencv_core220.dll
  • opencv_features2d220.dll
  • opencv_flann220.dll
  • opencv_gpu220.dll
  • opencv_highgui220.dll
  • opencv_imgproc220.dll
  • opencv_legacy220.dll
  • opencv_ml220.dll
  • opencv_objdetect220.dll
  • opencv_video220.dll

This error is covered along with others in my article on codeproject here.

Any other problems let me know,

Cheers,

Chris

Chris
  • 3,462
  • 20
  • 32
  • I just downloaded OpenCv version 2.4.10 and I cannot locate the files cudart64_32_16.dll, cufft64_32_16.dll, cvextern.dll and npp64_32_16.dll. Are these still needed? If so, they are NOT located in the build > x86 > vc12 > bin . Where could I find them? – RyeGuy May 10 '17 at 18:52
  • Do I really need all of these dll's installed on the target machine, only in order to run one simple function in emgu.world?? How can I know which exact one is needed? – ephraim Jul 25 '17 at 12:01
13

This error popped up on my side with Emgu CV 3.1 and I found for this issue a following working solution:

copy the cvextern.dll in the application directory \bin\Debug\

Hope this helps.

Haroldo Gondim
  • 7,725
  • 9
  • 43
  • 62
gyukov
  • 131
  • 1
  • 3
  • 1
    This problem only appeared when using Emgu in a Windows Forms User Control project which creates a dll rather than a .exe. Windows Forms applications using Emgu worked OK on the same machine. I fixed it by copying the cvextern.dll from /bin/Debug/x64 to /bin/Debug. Problem may be to do with dlls needing referenced dlls in the same folder, when .exes can reference dlls in other places. – SimonKravis Jul 16 '20 at 22:48
  • The problem appears in a Windows 8.1 64-bit installation of an application using Emgu.CV, but not in a Windows 10 installation. Tried copying cvextern.dll from the /x64 to the folder above (which contains the executable) but I then I get a Bad Image Format exception. Could it be something to do with Win8 being available as 32 and 64 bit OSs? – SimonKravis Sep 24 '20 at 06:50
3

The target probably needs to be specified as x64 or x86.

Details from an Emgu post on their GitHub:

If you are targeting .Net Framework, you need to target either "x64" or "x86". If you are targeting ".Net Core" or ".Net 5", you can target "AnyCPU". Detail can be found here: https://www.emgu.com/wiki/index.php/Download_And_Installation#Targeting_.Net_Framework

Lincoln
  • 1,008
  • 12
  • 20
2

The cvextern.dll should be in Windows\System32 for x86 and Windows\SysWOW64 for x64 it's work for me. ps: i used NuGet Package 'EmguCV' v3.1.0.1 with VS2015

2

I have solved this problem, by:

  • Right-click the project name, select Add, Select Add existing. Then select all files in the Emgu\libs\x64 folder to add to the project (allow to replace the old files if asked).
  • Then you need to select all the newly added files, right click and select Properties, In the Copy to Output section, select Copy Always.

It's done.

Hung Mta
  • 21
  • 4
1

I ran into this same error message, but none of these solutions worked for me. (Hate having a edge-case variant of a common problem...) Finally found it over battling for a couple hours.

I'm deploying with ClickOnce using version 4.1.1.3497 of Emgu.CV installed with Nuget. It would run great from Visual Studio, but the ClickOnce installation wouldn't. (On the same computer!) I found the missing DLLs in my project source folder (for me it was: ...\Visual Studio 2015\Projects\MyProjectName\packages\EMGU.CV.4.1.1.3497\build) But, for some reason they weren't being included in the Application Files of the Project Publish tab and thus weren't included in the ClickOnce installation. Once I figured that out the solution was simple--just add the DLLs to the project and set the properties as "Content"/"Copy Always".

E_net4
  • 27,810
  • 13
  • 101
  • 139
Jeff
  • 8,020
  • 34
  • 99
  • 157
1

for version 2.3 it`s list increases with opencv_ffmpeg.dll and opencv_flann231.dll.

no.oby
  • 11
  • 1
0

My problem for this error was that VS2015 was running the web project in 32 bit IIS Express. The fix was to ensure it was using 64 bit IIS Express

I added this code at startup to remind myself when setting up a new machine

if (IntPtr.Size != 8)
{
     throw new Exception("Change VS options to ensure 64bit IIS Express");
}
fiat
  • 15,501
  • 9
  • 81
  • 103
0

in my case I had switched to a 64 target and not noticed, going to x86 made this go away

twobob
  • 354
  • 8
  • 22
0

You can resolve this by installing it using Nuget Package Manager in Visual Studio 2019 Tools> NuGet Package Manager > Package Manager Console

And then install using this

  • Install-Package Emgu.CV
  • Install-Package Emgu.CV.runtime.windows

And everything worked fine for me.

Abraham
  • 12,140
  • 4
  • 56
  • 92