I have a program that I am debugging and requires connections to a MySQL database. I've noticed that when I close the program "normally" (as intended by the user) the connections close out as expected. When I click the Stop Debugging button in Visual Studio, the connections stay open on the server. I believe the underlying issue has something to do with improperly opening the connection in the first place but I did not write the original code and it would take an extensive amount of time to even try to find and fix each issue in the code. Until I have the time, is there a way to get Visual Studio to automatically close all MySQL connections when stopping the debug session? Maybe have it run some additional code on Stop Debug or something?
Asked
Active
Viewed 381 times
1
-
Are you putting your connections in `using(){}` constructs, or closing them in `finally{}` blocks? – O. Jones Nov 10 '16 at 22:19
-
@O.Jones I think that is what's going to need to happen when I get around to actually fixing it. I was wondering if there was a way to force them to close when I click the Stop Debugging button in VS 2015, for the time being. – John Haffenreffer Nov 14 '16 at 14:55
-
@John Haffenreffer, any update? Could you share the latest information about this issue? – Jack Zhai Nov 17 '16 at 10:53
-
@JackZhai-MSFT I have not found a solution yet. Doesn't seem like there is a way to make sure all connections are dealt with while debugging, except fix the code... – John Haffenreffer Dec 12 '16 at 20:44
1 Answers
0
The "Stop debugging" button in VS IDE would not stop the connection directly, one workaround is that you could close the connection in your code automatically during debugging. My understanding is that the real connection or not connection action is related to your code execution, it is not related to the VS debugging tool.
Even if you use the Finally block, please also check that whether it really calls the code in it after you stopping debugging.