Error in Visual Studio 2022 debugging data table visualizer - missing NewtonsoftSerializationHelper.dll or dependencies
Asked Answered
K

2

3

I have upgraded Visual studio 2022 to the latest updated release 17.7.4 from the previous build. From then, I'm getting an error "Internal error in Visualizer" when trying to visualize a C# DataTable during debugging. Simple Text Visualizer is working fine, but not Data Visualizer.

I tried repairing visual studio and restarted the system. Still the issue exists.

Screenshot from visual studio debugger

This is the error message when I click on View. It says 'Microsoft.VisualStudio.NewtonsoftSerializationHelper.dll' is missing.

---------------------------
Internal error in Visualizer
---------------------------
The Visualizer encountered an internal exception and must be closed.

Original type: System.IO.FileNotFoundException

Message: Could not load file or assembly 'file:///C:\Users\<USERNAME>\AppData\Local\assembly\dl3\G8ZYLRAT.R1O\AZG23WDE.2NW\16b08eda\Newtonsoft.Json\net4.5\Microsoft.VisualStudio.NewtonsoftSerializationHelper.dll' or one of its dependencies. The system cannot find the file specified.

Stack trace:

   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Microsoft.VisualStudio.DebuggerVisualizers.NewtonsoftJsonSerializarionUtilities.InitializeSerializationDelegates()
   at Microsoft.VisualStudio.DebuggerVisualizers.NewtonsoftJsonSerializarionUtilities.GetDeserializableObject(Stream serializationStream)
   at Microsoft.VisualStudio.DebuggerVisualizers.VisualizerObjectSource.GetDeserializableObject(Stream serializationStream)
   at Microsoft.VisualStudio.Debugger.DataSetVisualizer.DataSetVisualizerSource.TransferData(Object obj, Stream fromVisualizer, Stream toVisualizer)
   at Microsoft.VisualStudio.DebuggerVisualizers.DebuggeeSide.Impl.ClrCustomVisualizerDebuggeeHost.TransferData(Object visualizedObject, Byte[] uiSideData)
---------------------------
OK   
---------------------------
Kyne answered 4/10, 2023 at 8:36 Comment(13)
I have that file in the following locations (posted separately below because the paths are very long!) Do you have those?Pulpiteer
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Packages\Debugger\Visualizers\Newtonsoft.Json\net3.5Pulpiteer
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Packages\Debugger\Visualizers\Newtonsoft.Json\net4.5Pulpiteer
C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Packages\Debugger\Visualizers\Newtonsoft.Json\netstandard2.0Pulpiteer
yes, I do have the three folders in "C:\Program Files\Microsoft Visual Studio\2022\Professional\Common7\Packages\Debugger\Visualizers\Newtonsoft.Json" Each folder has two DLLsKyne
'Newtonsoft.Json.dll' and 'Microsoft.VisualStudio.NewtonsoftSerializationHelper.dll' are the two DLLsKyne
Yes, that's what I have. Sorry, I can't explain why it's looking for it in your User folder instead of the Visual Studio folder... I assume you've rebooted since upgrading VS. I suppose you could try copying the appropriate DLL into the folder where it says it's looking - that's not a very satisfactory solution tho...Pulpiteer
Yes, I have rebooted after upgrading VS and also after repairing VS. I'll try copying those DLLs to the specified folder and test. Thank you !Kyne
@MatthewWatson the workaround you suggested helped me to fix the issue. DataTable Visualizer is working again after copying the folder.Kyne
From VS2022 > Tools menu > Nuget Package Manager > Package Manager Console > Select Default Project (ComboBox) > typo: PM> NuGet\Install-Package Newtonsoft.Json -Version 13.0.3 > enter to install.Hydrops
@Hydrops my project already has a reference to Newtonsoft.Json. The error I got is related to VS Debug Visualizer, not specific to any project.Kyne
@YeshR Right click your project > Unload Project > right click it again > Reload Project and check if this error disappearsHydrops
This error is happening only for VS 2022 and for all projects where I debugging visualizer. If I use VS 2019, debugging visualizer works fine. But the workaround from MatthewWatson helped in fixing the issue for now.Kyne
S
1

I had the same issue in a project (net6.0) where I also had Newtonsoft.Json.DLL added as an assembly.

The dirty-fix solution was to copy (and overwrite) the referenced dll from my project into this VS folder:

C:\Program Files\Microsoft Visual Studio\2022\Enterprise\Common7\Packages\Debugger\Visualizers\Newtonsoft.Json\netstandard2.0

Copying the other way around (from VS to my project) also worked.

So I guess one of the more recent VS updates came with a newer Newtonsoft.Json.dll that is no longer compatible with an old version.

Sisera answered 11/3, 2024 at 15:10 Comment(0)
D
0

As discussed above, the problem is usually caused by an error that occurs when the .dll downloaded by Visual Studio is not in the correct referencing location.

We can deal with this problem in the following two ways:

  1. Put the .DLL file in the correct reference location (i.e. the path indicated in the error message)

  2. Check the project's .csproj file and change the reference address of the NuGet package to the path that is now .dll.

In addition, when encountering an error message about the NuGet package, we need to try to clean up the NuGet package storage or reinstall the selected NuGet package in the NuGet package manager to avoid unexpected failures such as file corruption.

Diopside answered 5/10, 2023 at 2:50 Comment(3)
The error is from the VS datatable visualizer, but not from any NuGet packages from the project. It's an issue related to VS 2022 debugging. The suggested answer is not helpful.Kyne
Hi @YeshR, I'm sorry I misunderstood the issue, and I found out that the issue has already been reported. developercommunity.visualstudio.com/t/… "A fix for this issue has been internally implemented and is being prepared for release." Therefore will Matthew Watson's method is a good choice as a temporary workaroundDiopside
You can also try disable "enable fast expression evaluation(Managed only)".(Main menu>Tools>Options>Debugging)Diopside

© 2022 - 2025 — McMap. All rights reserved.