Build/Test Issues

IpcConnectionClosedException - JSON parsing exception occurred

Started by stanac on 1,980 views

Getting following error message for all test projects in a solution. URL in the message does not mention IpcConnectionClosedException.


NCrunch 5.18.0.2, 
Visual Studio Community 2022 (64-bit) 17.14.14
xunit 2.9.3
xunit.runner.visualstudio 3.1.3



An error occurred while analysing this project after it was built: NCrunch encountered an unexpected error occurred while building an environment to analyse an assembly: The NCrunch task process failed to correctly initialise with the following exception: nCrunch.TaskRunner.Ipc.IpcConnectionClosedException: The NCrunch task process was unexpectedly terminated.  For information on how to troubleshoot this problem, please see https://www.ncrunch.net/documentation/troubleshooting_process-terminated-unexpected-error
   at nCrunch.TaskRunner.Ipc.Fast.IpcReader.Initialise()
   at nCrunch.Core.ProcessManagement.DefaultProcessLoader.ConnectToProcess(ExternalProcess externalProcess, ProcessLoadParameters parameters, Action`1 outOfBandMessageHandler)
   at nCrunch.Common.PerformanceTracking.PerfTracker.TrackActivity(String name, Action activity)
   at nCrunch.Core.ProcessManagement.ExternalProcessManager.launchProcess(EffectiveProcessorArchitecture processorArchitecture, ProcessLoadParameters parameters, Boolean forceRedirectOutput)

The trace output for the process is as follows: 
A JSON parsing exception occurred in [C:\Users\{username}\AppData\Local\NCrunch\14372\5\tests\{solutionName}.Analytics.Tests\bin\Debug\net9.0\nCrunch.TaskRunner.DotNetCore.20.x64.runtimeconfig.dev.json], offset 0 (line 1, column 1): Invalid value.
A JSON parsing exception occurred in [C:\Users\{username}\AppData\Local\NCrunch\14372\5\tests\{solutionName}.Analytics.Tests\bin\Debug\net9.0\nCrunch.TaskRunner.DotNetCore.20.x64.runtimeconfig.json], offset 0 (line 1, column 1): Invalid value.
Invalid runtimeconfig.json [C:\Users\{username}\AppData\Local\NCrunch\14372\5\tests\{solutionName}.Analytics.Tests\bin\Debug\net9.0\nCrunch.TaskRunner.DotNetCore.20.x64.runtimeconfig.json] [C:\Users\{username}\AppData\Local\NCrunch\14372\5\tests\{solutionName}.Analytics.Tests\bin\Debug\net9.0\nCrunch.TaskRunner.DotNetCore.20.x64.runtimeconfig.dev.json]


nCrunch.TaskRunner.DotNetCore.20.x64.runtimeconfig.dev.json file content:


{
    "runtimeOptions": {
        "configProperties": {
            "System.GC.Concurrent": false,
            "System.GC.Server": true
        },
        "additionalProbingPaths": [
            "C:\\Users\\{username}\\.dotnet\\store\\|arch|\\|tfm|",
            "C:\\Users\\{username}\\.nuget\\packages",
            "C:\\Program Files (x86)\\Microsoft Visual Studio\\Shared\\NuGetPackages",
            "C:\\Program Files\\dotnet\\sdk\\NuGetFallbackFolder"
        ]
    }
}



nCrunch.TaskRunner.DotNetCore.20.x64.runtimeconfig.json file content:


{
   "runtimeOptions": {
       "tfm": "net9.0",
       "framework": {
           "name": "Microsoft.AspNetCore.App",
           "version": "9.0.9"
       }
   }
}
Hi, thanks for sharing this issue.

The json here looks structurally correct and I can't see anything obviously wrong with what's specified. I think this might be an encoding issue.

What triggered this issue? Do you see if for every solution you use NCrunch on? Or just this one?
You are right, JSON looks correct. The thing is, this is happening only on one PC, on another one NCrunch is working. If it means anything it is working on desktop and failing on laptop, not sure if performance of the hardware plays any role.

I have tried deleting local (as in dir where solution file is) ncrunch dir and app data dir, it didn't help.

Issue occurred during larger refactoring, first I didn't pay any attention to it, since the solution wasn't building at all, now the solution is building but this issue persists.
Does the problem happen for all solutions? Or just one?

Can you inspect the .json files with a hex editor to see whether they have a BOM?

Edited

Yes, the problem is present for all solutions on this PC.

3 json files in the app data dir \tests\{project}\bin\debug\net9.0 have BOM "EF BB BF".
Ok, we're making progress :)

NCrunch v5.17 included this change:
- Fixed some files being written in ASCII when they should be in UTF8. This should give better support for non-english environments and projects.

The change was intended to resolve some localization issues around files being written by NCrunch. It may have had an unintended side-effect of adding a BOM that .NET doesn't like. It's not clear to me why it's causing problems on this machine but not others. Would you mind rolling back to v5.16 to see if the problem goes away?
After rolling back to 5.16 issue is no longer present on one of the projects. On another I have


An error occurred while analysing this project after it was built: System.IO.FileNotFoundException: Could not load file or assembly 'xunit.runner.utility.netcoreapp10, Version=2.4.1.0, Culture=neutral, PublicKeyToken=8d05b1bb7a6fdb6c'. The system cannot find the file specified.
I've prepared a build with some changes intended to prevent the writing of any BOMs to these json files. Would you be interested in giving it a try?

NCrunch_Console_5.18.0.3.msi
NCrunch_Console_5.18.0.3.zip
NCrunch_GridNodeServer_5.18.0.3.msi
NCrunch_GridNodeServer_5.18.0.3.zip
NCrunch_LicenseServer_5.18.0.3.zip
NCrunch_Rider_5.18.0.3.7z
NCrunch_Rider_5.18.0.3.zip
NCrunch_VS2010_5.18.0.3.msi
NCrunch_VS2010_5.18.0.3.zip
NCrunch_VS2012_5.18.0.3.msi
NCrunch_VS2012_5.18.0.3.zip
NCrunch_VS2013_5.18.0.3.msi
NCrunch_VS2013_5.18.0.3.zip
NCrunch_VS2015_5.18.0.3.msi
NCrunch_VS2015_5.18.0.3.msi.7z
NCrunch_VS2015_5.18.0.3.zip
NCrunch_VS2017_5.18.0.3.msi
NCrunch_VS2017_5.18.0.3.msi.7z
NCrunch_VS2017_5.18.0.3.zip
NCrunch_VS2019_5.18.0.3.msi
NCrunch_VS2019_5.18.0.3.msi.7z
NCrunch_VS2019_5.18.0.3.zip
NCrunch_VS2022_5.18.0.3.msi
NCrunch_VS2022_5.18.0.3.msi.7z
NCrunch_VS2022_5.18.0.3.zip
NCrunch_VS2026_5.18.0.3.msi
NCrunch_VS2026_5.18.0.3.msi.7z
NCrunch_VS2026_5.18.0.3.zip


The xunit dependency issue looks to be unrelated. Is it something you can reproduce with consistency?
Thank you, this build is working without issues. No more JSON problem and xunit runner issue might have been a hiccup, but it's no longer present.

Post a reply

Log in to reply.