【问题标题】:Emgu Could not found cvextern in IIS serverEmgu 在 IIS 服务器中找不到 cvextern
【发布时间】:2017-09-12 19:22:28
【问题描述】:

我在我的服务器上运行 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:

  • concrt140.dll*
  • liblept172.dll*
  • msvcp140.dll*
  • vcruntime140.dll*
  • cvextern.dll*
  • libtesseract304.dll*
  • opencv_ffmpeg320.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)

有人可以帮忙吗?

【问题讨论】:

    标签: c# asp.net-mvc iis emgucv


    【解决方案1】:

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

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

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

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

    3. 在远程服务器上安装Visual C++ Redistributable for Visual Studio(谷歌一下就可以找到下载链接。请根据你的VS版本,2013,2015选择下载版本、2017 年、2020 年、2050 年……)。即使您的操作系统是 x64,也请使用 x86 安装。

    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)授予文件安全性,如以下链接“http://www.iis.net/learn/manage/configuring-security/application-pool-identities”中所述,如果您的应用程序池正在用于defaulapppool,那么你应该添加用户“IIS AppPool\DefaultAppPool”

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

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

    希望对您有所帮助!

    【讨论】:

    • 我完成了所有 5 个操作,但仍然收到错误 Server Error in '/' Application.Unable to load DLL 'cvextern': The specified module could not be found. (Exception from HRESULT: 0x8007007E) 你能看看我能做些什么来进一步检查吗?
    • 哎呀,终于找到答案了,是关于桌面体验功能的转折,这里是链接stackoverflow.com/questions/44794807/…
    • 更新,我已经尝试将那些 dll 从 /bin 移回 /bin/x86,它仍然可以正常工作。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-02-18
    相关资源
    最近更新 更多