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.

0

11 Answers 11

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

2
  • 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, 2017 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, 2017 at 12:01
18

Just Install : this nuget package

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

See the ChangeLog

3
  • 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 at 6:40
  • @Seth you should choose the correct version or downgrade your target framework Feb 25 at 15:12
  • 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 at 4:07
12

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.

2
  • 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 <project>/bin/Debug/x64 to <project>/bin/Debug. Problem may be to do with dlls needing referenced dlls in the same folder, when .exes can reference dlls in other places. Jul 16, 2020 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? Sep 24, 2020 at 6: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

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.

1

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

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");
}
0

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

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.

0

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".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.