如何让应用程序使用特定版本的.NET?

发布于 2024-09-02 06:34:27 字数 1014 浏览 4 评论 0原文

我正在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

那小子欠揍 2024-09-09 06:34:27

为应用程序创建一个 .config 文件并插入/合并以下内容(当然是您想要的版本,这是针对 2.0 RTM 的): 例如,

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

即使对于 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):

<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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文