unable to load cvextern in a c# project
Asked Answered
A

11

33

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.

Avertin answered 6/11, 2011 at 16:37 Comment(0)
A
22

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

Argolis answered 7/11, 2011 at 18:21 Comment(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?Synecology
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?Sligo
S
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

Scandalmonger answered 24/6, 2020 at 11:46 Comment(4)
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. Yours
@Yours you should choose the correct version or downgrade your target frameworkScandalmonger
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 argumentsYours
i replace "windows" with "ubuntu" everythings works fineRigel
B
14

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.

Birdwell answered 20/3, 2016 at 1:2 Comment(2)
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.Nyasaland
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?Nyasaland
L
4

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

Lamanna answered 7/1, 2022 at 17:46 Comment(1)
You are right!. Changing the target to x64 solved my problemJuniejunieta
S
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

Somatic answered 17/3, 2017 at 16:52 Comment(0)
A
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.

Audiogenic answered 7/11, 2019 at 23:50 Comment(0)
L
1

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

Lumpfish answered 27/3, 2012 at 17:14 Comment(0)
I
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".

Infarct answered 5/9, 2022 at 21:9 Comment(0)
G
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");
}
Gulledge answered 14/11, 2016 at 7:52 Comment(0)
P
0

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

Posner answered 9/5, 2017 at 19:3 Comment(0)
B
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.

Bracteole answered 18/9, 2021 at 13:49 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.