An error occurred while analysing this project after it was built: System.BadImageFormatException: Could not load file or assembly 'file:///C:\Users\username\AppData\Local\NCrunch\15076\2\projectname.Tests\bin\Debug\net5.0\projectname.Tests.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.
File name: 'file:///C:\Users\username\AppData\Local\NCrunch\15076\2\projectname.Tests\bin\Debug\net5.0\projectname.Tests.dll'
at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, StackCrawlMark& stackMark)
at System.Reflection.Assembly.LoadFrom(String assemblyFile)
at nCrunch.Common.ExecutionPlatform.LoadAssembly(FilePath assemblyFilePath)
at nCrunch.TestExecution.RemoteTaskRunner.AnalyseAssembly(DescribedTestFrameworkDiscoverer[] applicableFrameworks, ComponentUniqueName testComponentUniqueName, PerfTracker perfTracker)
This happened after upgrading VS and projects to .net 5
RC is better than previous release, it can run tests, however it fails when C#9 "init" is used with "System.InvalidProgramException: Common Language Runtime detected an invalid program."
Problem is when a class is using init in property, nrunch reports error when calling constructor and setting that init property. Those same tests are passing in console "dotnet test" and VS test runner.
Thanks for sharing this issue. We've just identified a problem where the usage of the new property initialisers is causing the complier to emit an IL sequence that we aren't handling right with our instrumentation.
We're working on a way to fix this now and hope to have it included soon in the next fix release. A workaround for the time being is to turn off the 'Analyse line execution times' setting for the project involved.
I just tried 4.6.0.1 and I'm still experiencing the error with init properties:
System.InvalidProgramException: Common Language Runtime detected an invalid program.
at SpeakerMeet.Core.DTOs.CommunityResult.set_Id(Guid value)
at SpeakerMeet.Core.Services.CommunityService.Map(Community community) in C:\Development\SpeakerMeet.Api\src\SpeakerMeet.Core\Services\CommunityService.cs:line 79
at SpeakerMeet.Core.Services.CommunityService.Get(Guid id) in C:\Development\SpeakerMeet.Api\src\SpeakerMeet.Core\Services\CommunityService.cs:line 34
at SpeakerMeet.Core.Tests.Services.CommunityServiceTests.Get.ItReturnsCommunity() in C:\Development\SpeakerMeet.Api\tests\SpeakerMeet.Core.Tests\Services\CommunityServiceTests\Get.cs:line 32
at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass48_1.<<InvokeTestMethodAsync>b__1>d.MoveNext() in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\Runners\TestInvoker.cs:line 264
--- End of stack trace from previous location ---
at Xunit.Sdk.ExecutionTimer.AggregateAsync(Func`1 asyncAction) in C:\Dev\xunit\xunit\src\xunit.execution\Sdk\Frameworks\ExecutionTimer.cs:line 48
at Xunit.Sdk.ExceptionAggregator.RunAsync(Func`1 code) in C:\Dev\xunit\xunit\src\xunit.core\Sdk\ExceptionAggregator.cs:line 90