VS2022 Debug Hangs After Loading Large Program

This is a bit of a strange one, perhaps someone can shed some light on it for me?

The problem started after a minor change, reverting it didn’t help, I hadn’t worked on the program for some time so I think more likely it was broken by a VS2022 upgrade.

I build and start debugging, the usual loading messages go by, the device reboots and is waiting for the debugger, then it just hangs. For a day, if I leave it. However the program has loaded and will happily run if I reset the board, I just can’t start/attach the debugger.

Things I’ve tried so far:

  1. Restart VS2022
  2. Reboot the PC.
  3. Switch debugging from serial to USB
  4. Change to another SCM20260 device
  5. Change to another PC (new build, install VS2022/TinyCLR components from scratch)

none of which made any difference.

However if I open the same project with VS2019, it will go through the same load procedure and connect to the debugger as normal. So at least there is that!

And if I run a small project (blinky, RTC test, MassStorage test) with VS2022 it will happily connect and debug. So it appears to be something to do with size/timing of a large project and a recent change to VS2022.

Deployment and debug output below below. You can see the deployment area isn’t full.

Any suggestions appreciated

====================== TinyCLR Device Deployment Output
Looking for a device on transport 'Serial'.
Found device port 'Serial' with ID 'b5e54d5e-a217-47b9-b2af-b65f052999fa' for transport 'Serial'.
Starting device deployment.
Attempting to connect to device 'Serial:COM3': iteration 0.
Opening port '\\.\COM3'.
Attaching debugger engine.
Debugger engine attached.
Generating device specific assemblies.
	- AnodeMeter v4.2.8830.39953 with size 114,724 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\AnodeMeter.pe'.
	- ESP8266Library v1.0.0.0 with size 36,560 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\ESP8266Library.pe'.
	- mscorlib v2.2.0.7000 with size 72,556 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\mscorlib.pe'.
	- GHIElectronics.TinyCLR.Cryptography v2.2.0.7000 with size 8,424 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.Cryptography.pe'.
	- GHIElectronics.TinyCLR.Data.Xml v2.2.0.7000 with size 61,168 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.Data.Xml.pe'.
	- GHIElectronics.TinyCLR.Devices.Adc v2.2.0.7000 with size 2,612 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.Devices.Adc.pe'.
	- GHIElectronics.TinyCLR.Devices.Dac v2.2.0.7000 with size 2,228 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.Devices.Dac.pe'.
	- GHIElectronics.TinyCLR.Devices.Gpio v2.2.0.7000 with size 4,880 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.Devices.Gpio.pe'.
	- GHIElectronics.TinyCLR.Devices.I2c v2.2.0.7000 with size 10,464 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.Devices.I2c.pe'.
	- GHIElectronics.TinyCLR.Devices.Pwm v2.2.0.7000 with size 3,012 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.Devices.Pwm.pe'.
	- GHIElectronics.TinyCLR.Devices.Rtc v2.2.0.7000 with size 3,316 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.Devices.Rtc.pe'.
	- GHIElectronics.TinyCLR.Devices.Storage v2.2.0.7000 with size 3,432 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.Devices.Storage.pe'.
	- GHIElectronics.TinyCLR.Devices.Uart v2.2.0.7000 with size 8,012 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.Devices.Uart.pe'.
	- GHIElectronics.TinyCLR.Devices.Usb v2.2.0.7000 with size 1,156 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.Devices.Usb.pe'.
	- GHIElectronics.TinyCLR.Devices.UsbClient v2.2.0.7000 with size 21,112 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.Devices.UsbClient.pe'.
	- GHIElectronics.TinyCLR.Devices.Watchdog v2.2.0.7000 with size 1,652 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.Devices.Watchdog.pe'.
	- GHIElectronics.TinyCLR.IO v2.2.0.7000 with size 21,052 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.IO.pe'.
	- GHIElectronics.TinyCLR.IO.TinyFileSystem v2.2.0.7000 with size 16,372 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.IO.TinyFileSystem.pe'.
	- GHIElectronics.TinyCLR.Native v2.2.0.7000 with size 6,200 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.Native.pe'.
	- GHIElectronics.TinyCLR.Networking v2.2.0.7000 with size 12,600 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.Networking.pe'.
	- GHIElectronics.TinyCLR.Update v2.2.0.7000 with size 4,440 bytes at 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\GHIElectronics.TinyCLR.Update.pe'.
Total deployment size is 415,972 bytes.
Incrementally deploying assemblies to the device:
Allocating assemblies:
	- Address: 0x08140000 => AnodeMeter 
	- Address: 0x0815C024 => mscorlib 
	- Address: 0x0816DB90 => GHIElectronics.TinyCLR.Data.Xml 
	- Address: 0x0817CA80 => ESP8266Library 
	- Address: 0x08185950 => GHIElectronics.TinyCLR.Devices.UsbClient 
	- Address: 0x0818ABC8 => GHIElectronics.TinyCLR.IO 
	- Address: 0x0818FE04 => GHIElectronics.TinyCLR.IO.TinyFileSystem 
	- Address: 0x08193DF8 => GHIElectronics.TinyCLR.Networking 
	- Address: 0x08196F30 => GHIElectronics.TinyCLR.Devices.I2c 
	- Address: 0x08199810 => GHIElectronics.TinyCLR.Cryptography 
	- Address: 0x0819B8F8 => GHIElectronics.TinyCLR.Devices.Uart 
	- Address: 0x0819D844 => GHIElectronics.TinyCLR.Native 
	- Address: 0x0819F07C => GHIElectronics.TinyCLR.Devices.Gpio 
	- Address: 0x081A038C => GHIElectronics.TinyCLR.Update 
	- Address: 0x081A14E4 => GHIElectronics.TinyCLR.Devices.Storage 
	- Address: 0x081A224C => GHIElectronics.TinyCLR.Devices.Rtc 
	- Address: 0x081A2F40 => GHIElectronics.TinyCLR.Devices.Pwm 
	- Address: 0x081A3B04 => GHIElectronics.TinyCLR.Devices.Adc 
	- Address: 0x081A4538 => GHIElectronics.TinyCLR.Devices.Dac 
	- Address: 0x081A4DEC => GHIElectronics.TinyCLR.Devices.Watchdog 
	- Address: 0x081A5460 => GHIElectronics.TinyCLR.Devices.Usb 
Deploying assemblies:
	- Erasing sector 1 (131,072 bytes).
	- Writing sector 1 (131,072 bytes).
	- Writing sector 2 (131,072 bytes).
	- Writing sector 3 (131,072 bytes).
	- Writing sector 4 (22,784 bytes).
Assemblies deployed. There are 238,364 bytes left in the deployment area.
Restarting interpreter.
Attaching to device.
Waiting for device to initialize.

====================== Debug Output
Loading Deployment Assemblies.

Attaching deployed file.

   Assembly: AnodeMeter (4.2.8830.39953)  Attaching deployed file.

   Assembly: mscorlib (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Data.Xml (2.2.0.7000)  Attaching deployed file.

   Assembly: ESP8266Library (1.0.0.0)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Devices.UsbClient (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.IO (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.IO.TinyFileSystem (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Networking (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Devices.I2c (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Cryptography (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Devices.Uart (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Native (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Devices.Gpio (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Update (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Devices.Storage (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Devices.Rtc (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Devices.Pwm (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Devices.Adc (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Devices.Dac (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Devices.Watchdog (2.2.0.7000)  Attaching deployed file.

   Assembly: GHIElectronics.TinyCLR.Devices.Usb (2.2.0.7000)  Resolving.

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\mscorlib.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.Native.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.Devices.Dac.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.Devices.Gpio.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.Devices.Pwm.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.Devices.Usb.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.Devices.UsbClient.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.Devices.Storage.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.Devices.Rtc.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.Devices.Uart.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.Networking.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\ESP8266Library.dll', Symbols loaded.
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.Cryptography.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.Update.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.Devices.I2c.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.Devices.Watchdog.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.Devices.Adc.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.IO.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.IO.TinyFileSystem.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\GHIElectronics.TinyCLR.Data.Xml.dll'
'GHIElectronics.TinyCLR.VisualStudio.ProjectSystem.dll' (Managed): Loaded 'D:\usr\src\Alcoa\Projects\Potrod\Software\TinyCLR\AnodeMeter\AnodeMeter\bin\Debug\pe\..\AnodeMeter.exe', Symbols loaded.

1 Like

Have you tried making a new project and then add all your original sources?

1 Like

:grinning: Thanks Gus, good catch!

(It took a LONG time, there must be a faster way to add all those references? But I did find an unused SPI references, which saved me some space.)

Once done and everything resolved, the new project built, deployed, and progressed into the debugger with no problems.

I then compared project files and found no significant differences, so I deleted the .vs directories in the original project, started it up, they were rebuilt and things were back to operating normally.

1 Like

Sometimes a “reboot” is the easiest way!

3 Likes

GHI IT Department: Can you provide simple code? :stuck_out_tongue_winking_eye:

From ChatGPT:

The behavior you described, where the presence of the .vs directory affects the debugger’s ability to attach to the program being debugged, is not a commonly reported issue in Visual Studio. However, it’s not entirely unheard of, and issues related to Visual Studio’s configuration or cached data can sometimes lead to unexpected behavior.

Deleting the .vs directory can sometimes resolve such issues by resetting Visual Studio’s configuration and cached data. This action essentially forces Visual Studio to regenerate these files and directories with default settings, potentially resolving any underlying issues.

If you find that deleting the .vs directory fixes the problem with attaching the debugger, it’s likely that something within the .vs directory was causing interference with the debugging process. This could be due to corrupted or outdated cached data, conflicting settings, or other factors.

While it’s not a common occurrence, it’s worth keeping in mind as a troubleshooting step if you encounter similar issues in the future. If the problem persists or if you notice any patterns in when it occurs, it may be beneficial to report it to Microsoft through their feedback channels or support forums so that they can investigate further and potentially address any underlying issues in future updates to Visual Studio.

1 Like

Huh. And I thought I was wordy.

And that’s around 1/4 of what it had to say. I removed all the warnings about making sure to backup and what could go wrong if you delete the .vs files, etc. :grinning:

This happened to me when a lot of breakpoints accumulated throughout the project. It seems like you put 2-3 in a module, and then “voila” there are already 40 of them in the project. The debugger raises its paws up: “that’s all my authority”.