user1921922
user1921922

Reputation: 9

Visual Studio stops debugging VB.Net App after small code change - SOLVED

I have a fairly complex Application, which displays and manipulates data from various 'sensors' in my weather and home energy monitoring system, which I have developed over the course of years under incremental versions of Visual Studio/VB.Net. I am currently using Visual Studio 2022. The latest stable version of the Application continues to run without problems on my amply configured Asus-based Windows 11 desktop. In the last couple of days, I have made a number of small modifications to its main form and to the code in a subroutine behind it that configures the displayed data, in order to add another display field to the form. The modified program builds without errors. The first time I ran it from Visual Studio in Debug configuration, an exception was thrown in VB.Net core code referring to an uninitialized Object. I do not recall more details than that - I was in a hurry to get somewhere and assumed that I could record more details later. However, every subsequent attempt to run the Application ends with the debugger spontaneously resetting (as if the Stop Debugging button had been pressed) just after Form_Load returns. No exception is reported. Form_Load calls the subroutine I have modified, but stepping through the modified code confirms that it works (and returns) as expected. I have no idea where to start looking for whatever is causing this. Any helpful suggestions will be greatly appreciated.

{Edited to provide the solution} This turned out to be a very odd one! The stable version of the App runs on my main computer (the one I also use for development), displaying various pieces of information on the desktop. I believe that, in the past, I have generally (though I don't believe always) shut down the running App before testing updated versions. This should not be necessary - the App does not do anything which should cause problems if two instances of it are running. On this occasion, since the changes I was making were small and 'cosmetic', I left the previous, stable, version running when I tried to run the modified version under Visual Studio. This appears to have caused all the problems I saw, since, after shutting down the original instance, the modified version runs normally and correctly, both under Visual Studio and on its own. Oddly enough, I do have code early in Form_Load, which looks for a running instance of the Application and exits if it finds one, but this was not being triggered - as I noted, the abort occurred when Form_Load exited. I am not sure whether I regard this behavior as a bug or a feature, but it was certainly very confusing.

Upvotes: -1

Views: 76

Answers (0)

Related Questions