2012-07-10 26 views
0

我在x64上使用MSTest時遇到了問題:測試項目依賴於幾個C++/CLI程序集,並且由於某種原因無法加載。在Visual Studio中,我得到(精簡):x64上的MSTest C++/CLI

Error loading D:\xxx\Xxx.Test.dll: Unable to load the test container 'D:\xxx\Xxx.Test.dll' or one of its dependencies. Error details: System.BadImageFormatException: Could not load file or assembly 'Common.Geometry.Native, Version=1.1.4574.22395, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.

在命令提示符下手動運行MSTest的,我得到:

Unable to load the test container 'D:\xxx\Xxx.Test.dll' or one of its dependencies. Error details: System.IO.FileNotFoundException: Could not load file or assembly 'Common.Geometry.Native, Version=1.1.4574.22395, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

細節值得一提:

  • 測試項目本身是使用「任何Cpu」編譯的。
  • 我使用的x64特定testrunco​​nfig
  • 依賴助行示出了在C++/CLI組件(Common.Geometry.Native)無失天然依賴性
  • 更有趣的,存在使用在相同溶液中的另一測試項目相同的C++/CLI程序集(Common.Geometry.Native),它運行時沒有任何問題。

我也證實,沒有32位組件/ dll干擾。

歡迎任何建議!

回答

0

我最初以爲微軟沒有爲MSTest添加一個64位測試運行器,直到2012年......事實證明,VS2010能夠做到這一點。

我會檢查然後是如果您的本機DLL有任何其他本地依賴項。

MSTest有一個「錯誤功能」,在運行測試之前,它會創建一個臨時目錄(通常類似於PC-NAME WORKSPACE_NAME 1782368124\Out),並將代碼複製到該目錄中。對於.NET程序集,它可以找出依賴關係並能夠複製它們,但對於本機代碼,它似乎沒有這樣做。

我已通過添加含有任何其他本機的依賴到PATH環境變量我的用戶帳戶的目錄解決了這個在過去的(記住,如果你這樣做是爲了重新啓動Visual Studio,因爲它不會注意到)

+0

是的,您可以在VS-2010上運行64位測試,32位和64位QTAgents都隨附。 http://rupertrawnsley.blogspot.no/2011/04/mstest-and-64bit.html – Oyvind 2012-09-11 07:23:44

+1

你解決了這個問題嗎? – 2012-09-11 22:48:09