unable to load dll cvextern while using emgu cv for x86 platform


Requirement: Load a C# DLL(which uses Emgu.CV.World.dll for image comparison) into python project and call function inside DLL with some parameters.

I tried to export a DLL usig Emgu.CV.World.dll for image comparison. While compiling for "Any CPU" target, the DLL export was not working. After changed to x86 platform, DLL was loaded correctly from Python:

mydll = ctypes.cdll.LoadLibrary(self.libPath)

But while calling function inside the DLL:

ImageContentComparisonResult = mydll.CompareImageContent(self.OutputFile, self.OriginalFile)

throws the following exception:

WindowsError: [Error -532462766] Windows Error 0xE0434352

Output from Visual Studio:

A first chance exception of type 'System.IO.FileNotFoundException' occurred in Unknown Module.

After this, created a sample Emgu.CV project(GUI), got the same exception. There I got the exception details, like

{"The type initializer for 'Emgu.CV.CvInvoke' threw an exception."}
InnerException: {"Unable to load DLL 'cvextern': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"}

After copying the x86 and x64 DLLs for Emgu.CV to "bin\x86\Debug", it worked for the sample app, but for non GUI C# project, it's not working even after copying the required DLLs.

asked on Stack Overflow Oct 16, 2017 by Jibin.vp • edited Oct 18, 2017 by CristiFati

2 Answers


Copy the libs from \libs\x64, to my is: C:\Emgu\emgucv-windesktop_x64-cuda\libs\x64

answered on Stack Overflow Nov 12, 2017 by Marcelo Mohr Maciel

C# DLL will not be loaded using ctypes. Need to use clr.AddReference method included in python package. If python 2.7 is using need to uninstall clr package which comes as a part of 2.7 installation(This is to avoid namespace conflict). Or IronPython can be used for the same.

answered on Stack Overflow Nov 14, 2017 by Jibin.vp

User contributions licensed under CC BY-SA 3.0