Build/Test Issues

Problem with dotnet 5

Started by stanac on 3,674 views

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
We’re working to get a release out. I’ll post back when the release is out.
Thanks for prompt response, great to hear it's being worked on

Edited

Thanks for the patience would you mind trying this release candidate?

NCrunch_Console_4.5.0.3.msi
NCrunch_Console_4.5.0.3.zip
NCrunch_GridNodeServer_4.5.0.3.msi
NCrunch_GridNodeServer_4.5.0.3.zip
NCrunch_LicenseServer_4.5.0.3.zip
NCrunch_VS2008_4.5.0.3.msi
NCrunch_VS2010_4.5.0.3.msi
NCrunch_VS2010_4.5.0.3.zip
NCrunch_VS2012_4.5.0.3.msi
NCrunch_VS2012_4.5.0.3.zip
NCrunch_VS2013_4.5.0.3.msi
NCrunch_VS2013_4.5.0.3.zip
NCrunch_VS2015_4.5.0.3.msi
NCrunch_VS2015_4.5.0.3.msi.7z
NCrunch_VS2015_4.5.0.3.zip
NCrunch_VS2017_4.5.0.3.msi
NCrunch_VS2017_4.5.0.3.msi.7z
NCrunch_VS2017_4.5.0.3.zip
NCrunch_VS2019_4.5.0.3.msi
NCrunch_VS2019_4.5.0.3.msi.7z
NCrunch_VS2019_4.5.0.3.zip
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.
This solves the init property problem for me.
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



Feel free to clone the repo:

https://github.com/ovation22/SpeakerMeet.Api

Can you check if you have your 'Instrumentation Mode' set to 'Optimised'?
Yeah, that did it. Sorry, I didn't read closely enough to see how/where/that to set the instrumentation mode.

Thanks again!

Post a reply

Log in to reply.