Question Why won't some apps debug?

Joined
Sep 16, 2023
Messages
22
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:
Back
Top