NUnit isn't running Visual Studio 2010 code

2019-01-03 13:03发布

I'm trying to load a Visual Studio 2010 beta dll into the NUnit GUI. I get a popup error.

This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. You may be attempting to load an assembly build with a later version of the CLR than the version under which NUnit is currently running.

How do I force an executable to run under .NET 4?

10条回答
老娘就宠你
2楼-- · 2019-01-03 13:25

The proposed solution worked great for getting NUnit to run. Unfortunately, when I then got to my code coverage step, NCover started giving me:

Profiled process terminated. Profiler connection not established.

The best solution I found to this was to just use the "-x86" version of NUnit with NCover:

NCover.Console.exe nunit-console-x86.exe --additional params--

Works now.

查看更多
Melony?
3楼-- · 2019-01-03 13:28

With .NET 4 being released, I used

<supportedRuntime version="v4.0.30319" />

in the NUnit 2.5.4 exe.config instead of requiredRuntime, and the loadFromRemoteResources tag as shown above and all worked well. Thanks!

查看更多
爱情/是我丢掉的垃圾
4楼-- · 2019-01-03 13:29

I ran into the very same error message while running NUnit 2.4.8. As I had not upgraded in some time I installed the current NUnit (v2.5.9) and found that it now supports VS2010 assemblies. So if you have newly encountered this error check your NUnit version: as of December 2010 (or so) the only thing you need to do is upgrade NUnit.

查看更多
迷人小祖宗
5楼-- · 2019-01-03 13:30

In NUnit 2.5.5 you can specify in the command line the option /framework=net-4.0 and it is compatible with the new assemblies generated with the release of the latest VS2010.

查看更多
▲ chillily
6楼-- · 2019-01-03 13:33

To find your .net 4 version from the Visual [C# 2010 Express, or which ever] go to the Visual application's "About" under the menu's Help item. It should show up as the version under the Microsoft .NET Framework line on the top right hand side of the window.

查看更多
唯我独甜
7楼-- · 2019-01-03 13:33

As of NUnit 2.5.10 you can enable visual studio support in the GUI runner:

Tools-> Settings-> IDE Support

After that I was able to successfully attach to the nunit-agent.exe process which runs your assembly in a .NET 4.0 app domain

查看更多
登录 后发表回答