Index: visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/PluginDebuggerBase.cs |
diff --git a/visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/PluginDebuggerBase.cs b/visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/PluginDebuggerBase.cs |
index 595c2fa5eee3352e3e0a134148b9fa1baef55216..0d0e64b34cc96172104004accd9c2af1ac3a64eb 100644 |
--- a/visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/PluginDebuggerBase.cs |
+++ b/visual_studio/NativeClientVSAddIn/NativeClientVSAddIn/PluginDebuggerBase.cs |
@@ -123,6 +123,8 @@ namespace NativeClientVSAddIn |
/// <param name="unused1">The parameter is not used.</param> |
public void FindAndAttachToPlugin(object unused, EventArgs unused1) |
{ |
+ StringComparison ignoreCase = StringComparison.InvariantCultureIgnoreCase; |
+ |
// This function is called by the main Visual Studio event loop and we may have put the event |
// on the queue just before disposing it meaning this could be called after we've disposed. |
if (Disposed) |
@@ -130,8 +132,6 @@ namespace NativeClientVSAddIn |
return; |
} |
- StringComparison ignoreCase = StringComparison.InvariantCultureIgnoreCase; |
- |
// Set the main chrome process that was started by visual studio. If it's not chrome |
// or not found then we have no business attaching to any plug-ins so return. |
if (debuggedChromeMainProcess_ == null) |
@@ -148,10 +148,29 @@ namespace NativeClientVSAddIn |
return; |
} |
+ if (debuggedChromeMainProcess_.HasExited) |
+ { |
+ // Might happen if we're shutting down debugging. |
+ return; |
+ } |
+ |
// Get the list of all descendants of the main chrome process. |
uint mainChromeProcId = (uint)debuggedChromeMainProcess_.Id; |
List<ProcessInfo> chromeDescendants = processSearcher_.GetDescendants(mainChromeProcId); |
- string mainChromeFlags = chromeDescendants.Find(p => p.ID == mainChromeProcId).CommandLine; |
+ if (chromeDescendants.Count == 0) |
+ { |
+ // Might happen if we're shutting down debugging. |
+ return; |
+ } |
+ |
+ ProcessInfo mainProcInfo = chromeDescendants.Find(p => p.ID == mainChromeProcId); |
+ if (mainProcInfo == null) |
+ { |
+ // Might happen if we're shutting down debugging. |
+ return; |
+ } |
+ |
+ string mainChromeFlags = mainProcInfo.CommandLine; |
// From the list of descendants, find the plug-in by it's command line arguments and |
// process name as well as not being attached to already. |