문제

I have a set of tests that was initially built for .net 2.0. We use Gallio with MBunit to run them from the console using Gallio.Echo. Gallio insists on running the 2.0 CLR and then breaks when it sees that the test was built for .net 4.0. What am I doing wrong? Can I force Gallio to use .net 4? I definitely have 4 installed on the machine.

Error message:

Start time: 4:07 PM Initializing the runtime and loading plugins. Verifying test files. Initializing the test runner. Running the tests. Host started at 11/9/2011 4:08:00 PM. Running under CLR v2.0.50727 runtime. Host stopped at 11/9/2011 4:08:08 PM. Host process exited with code: 0 A fatal exception occurred while running tests. Possible causes include invalid test runner parameters and stack overflows. Gallio.Model.ModelException: An exception occurred while invoking a test driver. ---> Gallio.Model.ModelException: Gallio.Model.ModelException: Could not load test assembly from 'C:\tests\mytest.dll'. ---> System.BadImageFormatException: Could not load file or assembly 'file:///C:\tests\mytest.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

도움이 되었습니까?

해결책

If you use the "/runtime-version" attribute on the executable, you can specify exactly what version of the framework to load up - careful, it requires the value to match up exactly to the folder name in \Windows\Microsoft.Net\Framework\ - for example, "v4.0.30319"

다른 팁

This is most likely because your appname.exe.config defines a <startup> node that's forcing the runtime to 2.0.50727, e.g.:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <startup>
    <supportedRuntime version="v2.0.50727" />
  </startup>
</configuration>

Gallio inspects this file for this attribute and uses it if found. If not explicitly set, Gallio will fall back to autodetection of the .NET Framework version.

Hence, if you remove this <startup> node, Gallio should correctly detect and use the 4.0.30319 framework.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top