From 1f256c5327163a022594a3101160dd2fa29fe59e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Srbeck=C3=BD?= Date: Tue, 8 Dec 2009 19:21:25 +0000 Subject: [PATCH] Backported r5291 - General exception handler for CreateProcess git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@5312 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61 --- .../Project/Src/Service/WindowsDebugger.cs | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs index 8c337c4cae..363dfdd9d9 100644 --- a/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs +++ b/src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs @@ -41,9 +41,11 @@ using System; using System.Diagnostics; using System.Drawing; using System.IO; +using System.Runtime.InteropServices; using System.Security.Cryptography; using System.Text; using System.Windows.Forms; + using Debugger; using Debugger.AddIn; using Debugger.AddIn.TreeModel; @@ -58,7 +60,7 @@ using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor; using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Project; using BM = ICSharpCode.SharpDevelop.Bookmarks; -using Process=Debugger.Process; +using Process = Debugger.Process; namespace ICSharpCode.SharpDevelop.Services { @@ -180,10 +182,28 @@ namespace ICSharpCode.SharpDevelop.Services if (DebugStarting != null) DebugStarting(this, EventArgs.Empty); - Process process = debugger.Start(processStartInfo.FileName, - processStartInfo.WorkingDirectory, - processStartInfo.Arguments); - SelectProcess(process); + try { + Process process = debugger.Start(processStartInfo.FileName, + processStartInfo.WorkingDirectory, + processStartInfo.Arguments); + SelectProcess(process); + } catch (System.Exception e) { + // COMException: The request is not supported. (Exception from HRESULT: 0x80070032) + // COMException: The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log for more detail. (Exception from HRESULT: 0x800736B1) + // COMException: The requested operation requires elevation. (Exception from HRESULT: 0x800702E4) + // COMException: The directory name is invalid. (Exception from HRESULT: 0x8007010B) + // BadImageFormatException: is not a valid Win32 application. (Exception from HRESULT: 0x800700C1) + // UnauthorizedAccessException: Отказано в доступе. (Исключение из HRESULT: 0x80070005 (E_ACCESSDENIED)) + if (e is COMException || e is BadImageFormatException || e is UnauthorizedAccessException) { + string msg = StringParser.Parse("${res:XML.MainMenu.DebugMenu.Error.CannotStartProcess}"); + MessageService.ShowMessage(msg + " " + e.Message); + + if (DebugStopped != null) + DebugStopped(this, EventArgs.Empty); + } else { + throw; + } + } } }