2
votes

Environment:

C# 6

.NET Framework 4.6.1

NUnit Console 2.6.3


I am running the following command to create test coverage on my build:

"C:\Program Files (x86)\OpenCover.4.6.519\OpenCover.Console.exe" -target:"C:\Program Files (x86)\NUnit 2.6.3\bin\nunit-console.exe" -targetargs:"/nologo /noshadow .\UnitTests.nunit /xml=UnitTestResults.xml" -register -output:RawCoverageReport.xml -filter:"+[some name] -[some name]"

However, it's breaking my build on this version of OpenCover. On previous versions, the build does not break the build unit test but it doesn't create any test coverage. Any clues?

System.InvalidProgramException : Common Language Runtime detected an invalid program

Thank you all for your help!

1

1 Answers

3
votes

Although unrelated to OpenCover, we started seeing the same exception after installing .NET 4.6.1 when performing certain XSL transforms using the EXSLT library.

After some investigation and reinstalling incrementing versions of the .NET framework, we started to see the errors when .NET 4.6 was installed.

According to this document, a new JIT compiler is used by default once 4.6 in installed. This can be disabled on a per-application basis by adding the following entry to the app.config file.

<configuration>
  <runtime>
    <useLegacyJit enabled="1" />
  </runtime>
</configuration>

Having this flag set, stopped the exception occurring, not having made the exception reappear.

So, assuming that your problem has the same cause, you'll need to switch to the legacy JIT compiler when running OpenCover. Hopefully you can set the flag within the OpenCover app.config file. Otherwise you'll have to use one of the other methods for setting the flag as described in the article linked above.