Debug "Attach to Process" not working in VS 2022

Hello!

I am working on a TinyCLR project that has a very intermittent lockup issue and am in the process of troubleshooting to find it. I have been able to use the debugger which launches when deploying to the device with no issues, but this issue is infrequent enough that Murphy’s law has conspired so that it seems to never occur when just letting the application run with the debugger from startup.

The hope would be to attach to the process when the issue is actually occurring, but I am having trouble with Visual Studio’s “Attach to Process” option in the Debug menu. I can select “TinyCLR Device”, “USB” Connection Target, and see my device in Available Processes, but when trying to attach I get a very brief popup window stating:

“Unable to attach to the process. The 64-bit version of the Visual Studio Remote Debugger (MSVSMON.EXE) cannot be used to debug 32-bit processes or 32-bit dumps. Please use the 32-bit version instead.”

If I had to hazard a guess it appears like VS is trying to still use the default debugger engine instead of redirecting to the version appropriate for TinyCLR, or something along those lines. The usual searching has not turned up much so far, so I wanted to reach out and see if this should work as I currently have it imagined, and if so, would there be anything I can try on my end?

Extra details if helpful: Visual Studio 2022 V. 17.9.7, SC20260, TinyCLR Firmware and Extension V. 2.3.0.1000

(Also a quick obligatory “long time lurker, first time poster” comment, just wanted to say thank you for the discussions and advice provided on this forum so far, it has helped me quite a number of times while learning this platform. Much appreciated.)

What happens when you upload the program, restart the device without Visual Studio, and then try to attach the debugger? Does the reattachment process fail right away or is time is necessary?

Once the device has become dead to reattachment, can you upload a new copy?

If you reboot the device, can you attach the debugger?

If time is necessary for the problem to appear, it is likely that your program has gone into a tight loop, which would not allow the debugger to reattach.

Oh right, apologies for not explaining that part too well, this issue occurs regardless of operating condition, so even when the device is running just fine I am still getting the “Unable to Attach” error. Just to make sure I restarted the device as you mentioned and still can’t attach, only during an upload. I also get the issue on a simple “blink” program, so it appears it shouldn’t be related to the lockup.

When the device freezes up I can still upload a new copy, but that does of course clear the freeze as well, so it will be interesting to see whether I will be able to attach mid-process once I can get that part working normally.

I sometimes find myself switching to serial debug then connect a terminal software.

Then I look for garage collector messages and any other messages that I periodically send.

This helps me a lot

Agreed, thank you Gus, we’re doing similarly, adding debug and/or serial messages in key points, disabling sections of code and doing A/B tests, and I’m working on a simple test program that strips out everything but the bare essentials. If I can narrow it down to anything where I can ask more specific questions regarding the actual lockup issue itself I’ll create a separate thread, so as to not force you guys to juggle two problems in one subject. I feel a little bad that I provided that mostly for context but kinda muddied the subject up a bit, my apologies.

So if I were to ask about just the “Attach to Process” debug feature, are you guys able to use that in VS 2022 at all? If it works for you guys that tells me I still have to fix something on my end as I’ve never been able to get it to work myself. If nobody has had any luck with it I can still continue with other tools and then I’d at least know to stop fussing with it. :slight_smile:

Thanks guys.