Question Why won't some apps debug?

Joined
Sep 16, 2023
Messages
24
Programming Experience
10+
WHAT I HAVE:
Visual Basic 2019, .NET Framework 4.6+

MY PROBLEM:
Recently, my WinForms and Console apps--which ran fine before--refused to debug/run in the IDE. At first, the problem was that they would build and then abort (without executing a single statement), saying, "Program exited with code 0 (0x0)" in the Output window; I found that for many of them, turning on "Use Managed Compatibility Mode" solved the problem and enabled them to run. However (!!), some--and only some--programs still refuse to debug; they build and then mysteriously abort without any error message and without any exit message in the Output window! I tried toggling the managed-compatibility-mode option off and on again, cleaning and rebuilding the solution, exiting and restarting Visual Studio--and nothing worked for these programs. Other apps run fine now, but some refuse to debug if I change them; others debug fine even when changes are made. Also, when I create an all-new program, it won't debug.

What's going on?!
 
Last edited:
It's hard to say what exactly is happening but it sounds like VS is corrupt in some way. I would suggest performing a Repair, which is a specific option in the VS Installer. That should hopefully overwrite any corrupt files and fix your issue. It's possible that some projects have been damaged and would need specific measures to repair them. If you can't determine the nature of the damage, it may be quicker to simply create a new project and copy in the source files.

Note that this is an example of why it's good to use source control. If projects have been damaged, you'd be able to roll back to a last known good state and correct any damage without having to know what it was. The history may also be able to show you what the damage was. If you're not already doing so, I suggest that you start using some form of source control, e.g. Azure DevOps or GitHub.
 
It's hard to say what exactly is happening but it sounds like VS is corrupt in some way. I would suggest performing a Repair, which is a specific option in the VS Installer. That should hopefully overwrite any corrupt files and fix your issue. It's possible that some projects have been damaged and would need specific measures to repair them. If you can't determine the nature of the damage, it may be quicker to simply create a new project and copy in the source files.

Note that this is an example of why it's good to use source control. If projects have been damaged, you'd be able to roll back to a last known good state and correct any damage without having to know what it was. The history may also be able to show you what the damage was. If you're not already doing so, I suggest that you start using some form of source control, e.g. Azure DevOps or GitHub.

I did do a repair (followed by an update) and it didn't change anything! The projects that work, and the ones that don't, are exactly the same afterward; none suddenly started working or stopped working. As for creating a new project and copying/loading in the source files--as I indicated above, when I recently created a new WinForms app with no "user [non-designer] code", it wouldn't run--not even displaying a blank form! The good news is that all of the ones (so far) that don't work are simply small, experimental apps for testing VS features, my coding constructs, and the various DLLs I've written; the complex, professional apps I'm working on appear to still be working.

But I don't understand why some apps simply won't fire up--aborting before carrying out even the very first instruction--and yet leave no error message or exit message as to why (!!). It's as if the IDE thinks there's no code at all in these programs, when the source in the editor and the IDE settings clearly indicate that there's code to run! There also seems to be no rhyme or reason as to the nature of which programs run or don't run, and the debug Options are the same for them all.

(At least when none of my programs launched, and they all "exited with code 0 (0x0)", there was an online explanation [to someone with similar issues to that] about glitches in recent VS debuggers that using managed-compatibility mode would remedy. Now that I've done that, there seem to be some that debug/run just fine now, and some that abort right at the start with no message describing any "problem" at all. And I can't seem to find any online examples of anyone with a similar problem to my new, current one.)

What's most disturbing is my aforementioned (possible) inability to create a new WinForms project, even one with no non-designer code, and have it do anything (even just display an empty form);--that would make it difficult to "re-create" a WinForms project from scratch and re-load the source files as you advised above. (When I want to test new features piecemeal--outside a major app--I need to find an existing simple test-app that does work and modify it [to test more than it was initially designed to test].) It's hard to fix something when the IDE doesn't even seem to "know" there's a problem! (BTW, when I try to create a Console app, the console window closes--once again, without executing any code--before I can read any error/exit message--assuming it even bothers to display one at all.)

Any suggestion on how to figure out what's going on here?

PS. Perhaps GitHub would work for me once I've fixed my non-working projects, but Azure DevOps probably isn't up my alley (yet) because all my apps so far are desktop ones.
 
Last edited:
I did do a repair (followed by an update) and it didn't change anything! The projects that work, and the ones that don't, are exactly the same afterward; none suddenly started working or stopped working. As for creating a new project and copying/loading in the source files--as I indicated above, when I recently created a new WinForms app with no "user [non-designer] code", it wouldn't run--not even displaying a blank form! The good news is that all of the ones (so far) that don't work are simply small, experimental apps for testing VS features, my coding constructs, and the various DLLs I've written; the complex, professional apps I'm working on appear to still be working.

But I don't understand why some apps simply won't fire up--aborting before carrying out even the very first instruction--and yet leave no error message or exit message as to why (!!). It's as if the IDE thinks there's no code at all in these programs, when the source in the editor and the IDE settings clearly indicate that there's code to run! There also seems to be no rhyme or reason as to the nature of which programs run or don't run, and the debug Options are the same for them all.

(At least when none of my programs launched, and they all "exited with code 0 (0x0)", there was an online explanation [to someone with similar issues to that] about glitches in recent VS debuggers that using managed-compatibility mode would remedy. Now that I've done that, there seem to be some that debug/run just fine now, and some that abort right at the start with no message describing any "problem" at all. And I can't seem to find any online examples of anyone with a similar problem to my new, current one.)

What's most disturbing is my aforementioned (possible) inability to create a new WinForms project, even one with no non-designer code, and have it do anything (even just display an empty form);--that would make it difficult to "re-create" a WinForms project from scratch and re-load the source files as you advised above. (When I want to test new features piecemeal--outside a major app--I need to find an existing simple test-app that does work and modify it [to test more than it was initially designed to test].) It's hard to fix something when the IDE doesn't even seem to "know" there's a problem! (BTW, when I try to create a Console app, the console window closes--once again, without executing any code--before I can read any error/exit message--assuming it even bothers to display one at all.)

Any suggestion on how to figure out what's going on here?

PS. Perhaps GitHub would work for me once I've fixed my non-working projects, but Azure DevOps probably isn't up my alley (yet) because all my apps so far are desktop ones.

Here's a new and bizzare twist:

A long time ago, I started the practice of backing up everything in my system-drive VS-solutions parent folder ("c:\directory chain\Visual Studio Projects") on a folder on an external drive ("extdrive:\Visual Studio Project BACKUPS"). I just found that whenever I try to run any of these solutions off the external-drive folder, they all debug/run ok! Yet only some will run when I try to run them off the main drive!

Thinking that some of the projects on the main drive were corrupted, I tried removing a subfolder for a problematic project from the main-drive folder ("Visual Studio Projects") and then copying it back there from the external-drive folder ("Visual Studio Project BACKUPS")--and it still wouldn't run! Thinking that part of the main drive might be compromised, I tried creating a second (all-new) all-solutions folder ("c:\directory chain\Visual Studio Projects II") on the main drive and copying the projects from the external-drive folder ("Visual Studio Project BACKUPS") thereto. Still wouldn't work when I tried running from the new folder ("Visual Studio Projects II")! Since the project files and folders in the new main-drive parent folder ("Visual Studio Projects II") are separate copies from those on the original main-drive parent folder ("Visual Studio Projects") and therefore occupy different space on the main drive, issues with the main drive can't necessarily be the problem--at least not the entirety of it, since I've been copying project folders from the main drive to the external drive even after the problems first materialized. Could VS itself now suddenly be "preferring" that projects not be on the same drive as itself? (Makes no sense.) Should I try another installation repair?

Having to rely soley on an external drive--which is invariably somewhat slower--seems like a poor solution to my project-and-solution problems. (That sentence was awkward.) I should point out that I did a little housecleaning on my system drive before I started having these issues:

As my system seemed to be crashing and/or getting very slow on me a few days earlier, I reverted my system drive to a system image I saved a few days before that. (I make backups [using Macrium Reflect] every few days of my entire system in case something like that happens! Of course, I also backed up my important data--including my all-solutions folder [as mentioned above]--separately, so that I can recover recent data changes after reverting to a backup-up system image. ) Thereafter, I removed some apps I never use (none of them related to VS as far as I can tell) as well as installing some new ones; then I defragmented my system drive and registry. The system is now faster and more reliable overall, but, as I point out, I'm having issues with some (and only some) of my projects when running them off the system drive (but not the external drive). I plan to do another system-image backup and a disk check on drive C. Is there anything else I can do?
 
Last edited:
Back
Top