我已在项目中使用NuGet管理器安装了最新的OpenCVSharp 2(2.4.10.201...)。关于OpenCVSharp.CvMat的所有内容(加载、操作等)都能正常工作,因此我确信安装是正确的。
然而,我完全无法使用OpenCVSharp.CPlusPlus!问题在于它无法加载OpenCvSharpExtern.dll。
从try-catch块中显示的错误:
然而,我完全无法使用OpenCVSharp.CPlusPlus!问题在于它无法加载OpenCvSharpExtern.dll。
从try-catch块中显示的错误:
try
{
Mat mat = new Mat();
} catch (Exception err)
{
Console.WriteLine( err );
}
System.TypeInitializationException: The type initializer for 'OpenCvSharp.CPlusPlus.Mat' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'OpenCvSharpExtern': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
at OpenCvSharp.CPlusPlus.NativeMethods.core_Mat_sizeof()
at OpenCvSharp.CPlusPlus.Mat..cctor()
--- End of inner exception stack trace ---
at OpenCvSharp.CPlusPlus.Mat..ctor()
at MainClass.Main() in C:\Users\kotsias\Documents\Visual Studio 2015\Projects\MyCVSharp\ConsoleApplication1\Test.cs:line 14
OpenCvSharpExtern.dll 已经被部署在以下子文件夹中,随我的 .exe 文件一起:
..\dll\x86
&
..\dll\x64
如果我手动将x64 .dll复制到与我的 .exe 文件相同的文件夹中,仍会出现上述错误。如果我复制x86 .dll,则会出现不同的错误:
System.TypeInitializationException: The type initializer for 'OpenCvSharp.CPlusPlus.Mat' threw an exception. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
at OpenCvSharp.CPlusPlus.NativeMethods.core_Mat_sizeof()
at OpenCvSharp.CPlusPlus.Mat..cctor()
--- End of inner exception stack trace ---
at OpenCvSharp.CPlusPlus.Mat..ctor()
at MainClass.Main() in C:\Users\kotsias\Documents\Visual Studio 2015\Projects\MyCVSharp\ConsoleApplication1\Test.cs:line 14
OpenCVSharp4.runtime.*
解决了我的问题。 - taylorswiftfan