Target Library: DLL file that build by VC++ 2005.
工作上, 因為要在 Windows Form上使用舊有的native C++ DLL,
花了好一段時間解這個問題.
其中當然包括上網Google "因為應用程式的並列設定不正確"這個字串, 然後試了一些
可能有用 卻無效的方式.
後來發現要debug, 還是少用中文, 因為中文的Error Message是:
Unable to load DLL 'ECGAlgorithmWin32.dll': 因為應用程式的並列設定不正確,所以無法啟動。如需詳細資訊,請參閱應用程式事件記錄檔,或使用命令列工具 sxstrace.exe。 (Exception from HRESULT: 0x800736B1)然而經由最後一段代碼, 查得英文的的Message是:
Unable to load DLL exception. This application has failed to start because the application configuration is incorrect ...所以一直被"並列設定不正確"所誤導debug方向阿 T.T"
最終找到一個非常有用的MSDN BLOG,
作者的一段文字, 整個就是如雷貫耳:
So now a big hint: that usually does not mean that your DLL is not found (although that’s possible), it usually means that your DLL depends on other DLLs that are missing. It usually happens when you develop on one machine, and deploy/run on another, especially if it has a different version of Windows or misses Visual Studio.讀完文章內容, 配合底下高手們的討論, 得知有兩個方法可以解, 我用了第一個, Done!
Method.1:
將當初所用的VC++ 2005專案, 在專案設定中, Configuration Properties-->Project Default-->Use of MFC-->改為 "Use MFC in a Static Library"
這樣可以避免因為使用者電腦上沒有MFC 8.0的相關dll可供dynamic link而導致出錯.
修改前後的dll尺寸大約差了10倍, 但是Solved this issue perfectly. :D
Method.2: (Not validate by myself yet!!!, but this may be helpful to the situation that is without source codes of DLL.)
Because the target dll is made on VC2005, so you need "Microsoft Visual C++ 2005 Redistributable Package".
Especially notice the version of VC++ 2005:
Default version, you can download this one:
Microsoft Visual C++ 2005 Redistributable Package
With VC++ 2005 SP1, you should download this one:
Microsoft VisualC++ 2005 SP1 Redistributable Package
Try and hope these methods will give you some helps.
and thanks my colleagues, Jerry and Kevin, for idea assistance in solving this issue.
沒有留言:
張貼留言