diff options
-rw-r--r-- | Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachineManager.cs | 4 | ||||
-rw-r--r-- | Mono.Debugging.Soft/SoftDebuggerSession.cs | 16 |
2 files changed, 13 insertions, 7 deletions
diff --git a/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachineManager.cs b/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachineManager.cs index f6bfd94..5bc2435 100644 --- a/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachineManager.cs +++ b/Mono.Debugger.Soft/Mono.Debugger.Soft/VirtualMachineManager.cs @@ -338,7 +338,9 @@ namespace Mono.Debugger.Soft public static void CancelConnection (IAsyncResult asyncResult) { - ((Socket)asyncResult.AsyncState).Close (); + //AsyncState could be null if the debugger incoming connection doesn't happen, so there's no socket between debugger and debuggee + //This could occur if the debugger session started but the connection to the app failed at some point + ((Socket)asyncResult.AsyncState)?.Close (); } public static VirtualMachine Connect (Connection transport, StreamReader standardOutput, StreamReader standardError) diff --git a/Mono.Debugging.Soft/SoftDebuggerSession.cs b/Mono.Debugging.Soft/SoftDebuggerSession.cs index fd22b2e..a173d25 100644 --- a/Mono.Debugging.Soft/SoftDebuggerSession.cs +++ b/Mono.Debugging.Soft/SoftDebuggerSession.cs @@ -386,12 +386,16 @@ namespace Mono.Debugging.Soft { HideConnectionDialog (); if (connection != null) { - if (startArgs != null && startArgs.ConnectionProvider != null) { - startArgs.ConnectionProvider.CancelConnect (connection); - startArgs = null; - } else { - VirtualMachineManager.CancelConnection (connection); - } + try {
+ if (startArgs != null && startArgs.ConnectionProvider != null) {
+ startArgs.ConnectionProvider.CancelConnect(connection);
+ startArgs = null;
+ } else {
+ VirtualMachineManager.CancelConnection(connection);
+ }
+ } catch(Exception e) {
+ DebuggerLoggingService.LogError("Unhandled error canceling the debugger connection", e);
+ }
connection = null; } } |