2010-05-19 60 views
1

我使用pnunit運行在遠程機器上NUnit的測試中,pnunit代理加載測試並運行在Windows 2008,但測試失敗在Windows 2003中加載,代理誤差如何讓應用程序使用特定版本的.NET?

INFO PNUnit.Agent.PNUnitAgent - Registering channel on port 9080 
INFO PNUnit.Agent.PNUnitAgent - RunTest called for Test MyTest, AssemblyName test.dll, TestToRun test.Program.myDeployTest 
INFO PNUnit.Agent.PNUnitTestRunner - Spawning a new thread 
INFO PNUnit.Agent.PNUnitTestRunner - Thread entered for Test MyTest:test.Program.myDeployTest Assembly test.dll 

Unhandled Exception: System.BadImageFormatException: The format of the file 'test 
' is invalid. 
File name: "test" 

Server stack trace: 
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, B 
oolean isStringized, Evidence assemblySecurity, Boolean throwOnFileNotFound, Ass 
embly locationHint, StackCrawlMark& stackMark) 

在運行將procmon並監視代理進程,我可以看到代理可執行文件在Windows 2003上使用.NET 1.1程序集,在Windows 2008上使用.NET 2.0,這可能是對此行爲的解釋。我如何讓代理在Windows 2003上使用.NET 2.0?我正在使用Visual Studio 2005來創建測試。

+0

是Windows 2003 x86和Windows 2008 x64? – 2010-05-19 13:52:36

+1

您可以確認.net 2.0安裝在2003計算機上嗎?奇怪的是,它沒有選擇.Net 2.0,如果它安裝在2003盒子上,因爲它默認使用2008機器上的.Net 2.0框架。 – Sijin 2010-05-19 13:57:22

+0

@Sijin,爲什麼會這麼奇怪?默認情況下,根據我過去對這個問題的經驗,我可以確切地選擇精確的匹配運行時。因此,如果您要在1.1和2.0的計算機上運行1.0應用程序,則它可能會加載2.0,但1.1版本的計算機上的1.1應用程序將加載1.1加入我的體驗。 – Lucero 2010-05-19 21:35:55

回答

0

爲應用程序創建一個.config文件,並插入/合併以下(當然你想要的版本,這是2.0 RTM):

<configuration> 
    <startup> 
    <supportedRuntime version="v2.0.50727"/> 
    <requiredRuntime version="v2.0.50727" safemode="true"/> 
    </startup> 
</configuration> 

例如,這將加載.NET 2甚至1.1應用程序或非託管應用程序激活1.1 COM對象。

+0

謝謝你,工作 – carrutherji 2010-05-20 05:49:08

相關問題