开发者

How to get application to use specific version of .NET?

开发者 https://www.devze.com 2022-12-30 16:39 出处:网络
I am using pnunit to run nunit tests on remote machines, the pnunit agent loads the test and runs it in Windows 2008 but the test fails to load in Windows 2003, the agent error is

I am using pnunit to run nunit tests on remote machines, the pnunit agent loads the test and runs it in Windows 2008 but the test fails to load in Windows 2003, the agent error is

INFO  PNUnit.Agent.PNUnitAgent - Registering channel on port 9080
INFO  PNUnit.Agent.PNUnitAgent - RunTest called for Test MyTest, AssemblyName t开发者_高级运维est.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)

On running procmon and monitoring the agent process i could see that the agent executable was using .NET 1.1 assemblies on Windows 2003 and .NET 2.0 on Windows 2008 which could be an explanation for this behavior. How do I get the agent to use .NET 2.0 on Windows 2003? I am using Visual Studio 2005 to create the tests.


Create a .config file for the application and insert/merge the following (of course with the version you want, this is for 2.0 RTM):

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

This for instance will load .NET 2 even for a 1.1 application or if a unmanaged application activates a 1.1 COM object.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号