问题
I tried to use EmguCV library in Windows 8 Store App. Previously, it works fine for a Windows 7 Desktop App project.
I ensure my Windows 8 Store App project directory [C:\Projects\App2\App2\bin\Debug] is having all the necessary DLLs file.

When I execute directly in Microsoft Visual Studio 2012 Ultimate through Local Machine button, I get the following exception.

Exception:Thrown: "Unable to load DLL 'opencv_core240': The specified module could not be found. (Exception from HRESULT: 0x8007007E)" (System.DllNotFoundException) A System.DllNotFoundException was thrown: "Unable to load DLL 'opencv_core240': The specified module could not be found. (Exception from HRESULT: 0x8007007E)"
My question is : How can I know whether the failure is caused by my Windows 8 Store App unable to locate the DLL files? Or, the located DLL files is not in the format expected by Windows 8 Store App? (The DLLs are OK for Windows 7 desktop software)
If the reason is caused by the format is not recognized by Windows 8 Store App, does re-compile the whole DLL project (The OpenCV source code is in C++, and EmguCV which acts as a wrapper is in C#) under Windows Store -> Class Library (Windows Store apps) will help?
回答1:
If these dlls worked for Windows 7 desktop apps, then they won't work for Windows 8 Metro apps, because it's completely different platform and API. You cannot load just any dll in your Windows 8 WinRT project.
If you have source code for the dll, you can try to recompile it as a Windows Runtime Component, byt there is a strong possibility the original code used APIs not available in WinRT.
回答2:
Look at the following two posts to see how OpenCV or other 3rd party libraries can be made to work with Windows 8 Store apps:
Using OpenCV in a Windows Store app with Visual C++
Using a C++ Library (built using Visual C++ 2010) in a Windows 8 Store app (built using Visual C++ 2012)
来源:https://stackoverflow.com/questions/12831213/knowing-the-reason-of-dll-loading-failed-for-windows-store-app