Emgu 无法在 IIS 服务器中找到 cvextern

Emgu Could not found cvextern in IIS server

我的服务器上的 Emgu 运行 有一些问题。它在本地运行良好,但是当我尝试在带有 IIS 的服务器上使用它时,它不起作用。

这里是错误:

System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception. ---> System.DllNotFoundException: Unable to load DLL 'cvextern': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)\r\n   at Emgu.CV.CvInvoke..cctor()
   --- End of inner exception stack trace ---
   at Emgu.CV.CvInvoke.cvCreateImageHeader(Size size, IplDepth depth, Int32 channels)
   at Emgu.CV.Image`2.AllocateData(Int32 rows, Int32 cols, Int32 numberOfChannels)
   at Emgu.CV.Image`2.set_Bitmap(Bitmap value)
   at VerifyID.Managers.ImageTreatmentsManager.ExtractDocumentFromImage(Bitmap bitmap)
   at VerifyID.VerifyWorker.ExecuteOCR(BigIdRequest request, BigIdEvent bigIdEvent)

我在 x86 和 x64 中有以下 dll:

IIS 版本:10.0

将 x64 dll 直接复制到构建的 bin 目录后,错误更改为:

System.TypeInitializationException: The type initializer for 'Emgu.CV.CvInvoke' threw an exception. ---> System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
   at Emgu.CV.CvInvoke.RedirectError(CvErrorCallback errorHandler, IntPtr userdata, IntPtr prevUserdata)
   at Emgu.CV.CvInvoke..cctor()
   --- End of inner exception stack trace ---
   at Emgu.CV.CvInvoke.cvCreateImageHeader(Size size, IplDepth depth, Int32 channels)
   at Emgu.CV.Image`2.AllocateData(Int32 rows, Int32 cols, Int32 numberOfChannels)
   at Emgu.CV.Image`2.set_Bitmap(Bitmap value)
   at VerifyID.Managers.ImageTreatmentsManager.ExtractDocumentFromImage(Bitmap bitmap)
   at VerifyID.VerifyWorker.ExecuteOCR(BigIdRequest request, BigIdEvent bigIdEvent)

有人可以帮忙吗?

我遇到了同样的问题,该应用程序在本地服务器(Visual Studio 使用的 IIS Express)上运行良好,但在远程 Windows 服务器上运行不正常,对我有用的解决方案是:

(请在每个步骤之间测试您的应用程序,也许您不需要全部执行)

  1. 在Visual Studio中,打开您的应用程序项目属性并将"Platform"设置为"Any CPU"。然后将您的应用程序发布到远程服务器。

  2. x86文件夹里面的所有.dll文件移动到bin文件夹下,特别注意cvextern.dll,它必须与您的应用程序 dll 并排在 bin 文件夹中。

  3. 在远程服务器上为 Visual Studio 安装 Visual C++ Redistributable(只需 google 它,您将找到下载 link.请根据自己的VS版本选择下载版本,2013、2015、2017、2020、2050...)。使用 x86 安装,即使您切断 OS 是 x64。

  4. 为 运行 32 位应用程序激活您的 app_pool。 https://help.webcontrolcenter.com/kb/a1114/how-to-enable-32-bit-application-pool-iis-7-dedicatedvps.aspx

  5. 转到应用程序 \bin 文件夹,为文件夹 "x86"(包含 emgu 的所有 dll)授予文件安全性,如下所述 link" http://www.iis.net/learn/manage/configuring-security/application-pool-identities 如果你的应用程序池在 defaulapppool 中使用,那么你应该添加用户 "IIS AppPool\DefaultAppPool"

我真的不知道为什么这些 dll 的 x64 版本不能在我的服务器上运行。我仍在调查它,一旦我发现为什么我会更新这个 post。

另一种解决方案(一点也不优雅,但有效)是在服务器上安装 Visual Studio,执行与开发环境相同的安装过程。通过这样做,您将在服务器上安装所需的所有依赖项和 dll(包括 Visual C++)。

希望对您有所帮助!