Browse Source

Backported r5291 - General exception handler for CreateProcess

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@5312 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
David Srbecký 16 years ago
parent
commit
1f256c5327
  1. 30
      src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs

30
src/AddIns/Misc/Debugger/Debugger.AddIn/Project/Src/Service/WindowsDebugger.cs

@ -41,9 +41,11 @@ using System;
using System.Diagnostics; using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Runtime.InteropServices;
using System.Security.Cryptography; using System.Security.Cryptography;
using System.Text; using System.Text;
using System.Windows.Forms; using System.Windows.Forms;
using Debugger; using Debugger;
using Debugger.AddIn; using Debugger.AddIn;
using Debugger.AddIn.TreeModel; using Debugger.AddIn.TreeModel;
@ -58,7 +60,7 @@ using ICSharpCode.SharpDevelop.DefaultEditor.Gui.Editor;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
using BM = ICSharpCode.SharpDevelop.Bookmarks; using BM = ICSharpCode.SharpDevelop.Bookmarks;
using Process=Debugger.Process; using Process = Debugger.Process;
namespace ICSharpCode.SharpDevelop.Services namespace ICSharpCode.SharpDevelop.Services
{ {
@ -180,10 +182,28 @@ namespace ICSharpCode.SharpDevelop.Services
if (DebugStarting != null) if (DebugStarting != null)
DebugStarting(this, EventArgs.Empty); DebugStarting(this, EventArgs.Empty);
Process process = debugger.Start(processStartInfo.FileName, try {
processStartInfo.WorkingDirectory, Process process = debugger.Start(processStartInfo.FileName,
processStartInfo.Arguments); processStartInfo.WorkingDirectory,
SelectProcess(process); 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;
}
}
} }
} }

Loading…
Cancel
Save