1

I created prove-of-concept console application, which is using EmguCV for template matching. Version of openCV is 2.4.

Now I have problems with my real-life asp.net mvc application. I have a runtime error:

The type initializer for 'Emgu.CV.CvInvoke' threw an exception. System.DllNotFoundException: Unable to load DLL 'opencv_core2410': The specified module could not be found.

Saw several other question, but they are incomplete or don't have answers:

  1. How use EmguCV in a MVC.NET project

  2. Error:The type initializer for 'Emgu.CV.CvInvoke' threw an exception

What I've already tried:

  1. Copied folders x64 and x86 from EmguCV installation into published bin folder(these folders contains opencv dlls)

  2. Added opencv dlls to my web project and set them to "Copy to output directory" as described here: http://www.codeproject.com/Articles/257502/Creating-Your-First-EMGU-Image-Processing-Project

  3. Please note, it's working well in concole application, but not in mvc.

Community
  • 1
  • 1
Ulad Melekh
  • 924
  • 3
  • 17
  • 33

2 Answers2

0

Well, I couldn't find normal solution for this problem.

In the topic How use EmguCV in a MVC.NET project there is an info, that EmguCV works with IIS only, not IIS Express. Nope, I've got the same error with it even published on our prod server.

So the only way, how it worked for me was:

  1. Create console app, which uses EmguCV and process my images.
  2. Call it from .net mvc app as .exe file with parameters.

I'm marking my question as answered, but this is more a dirty hack, than a good solution.

Community
  • 1
  • 1
Ulad Melekh
  • 924
  • 3
  • 17
  • 33
0

the solution from How use EmguCV in a MVC.NET project

is partially correct, there are two main changes that need to be made before EMGU will work under IIS

  1. activate your app_pool for the application for running 32 bit https://help.webcontrolcenter.com/kb/a1114/how-to-enable-32-bit-application-pool-iis-7-dedicatedvps.aspx

  2. then you need to go to the application \bin folder, grant the file security for the folder "x86" (which contains all the dll for emgu) as described in following link http://www.iis.net/learn/manage/configuring-security/application-pool-identities

    if your apppool being in used in defaulapppool, then you should add user "IIS AppPool\DefaultAppPool"

this took me 5 hours to figure out!!!

Community
  • 1
  • 1
user3453552
  • 199
  • 1
  • 2
  • 11