如何让应用程序使用特定版本的.NET?
我正在使用 pnunit 在远程计算机上运行 nunit 测试,pnunit 代理加载测试并在 Windows 2008 中运行它,但测试无法在 Windows 2003 中加载,代理错误是
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 来创建测试。
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 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)
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为应用程序创建一个
.config
文件并插入/合并以下内容(当然是您想要的版本,这是针对 2.0 RTM 的): 例如,即使对于 1.1 应用程序,这也会加载 .NET 2或者如果非托管应用程序激活 1.1 COM 对象。
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):This for instance will load .NET 2 even for a 1.1 application or if a unmanaged application activates a 1.1 COM object.