I was glad to integrate your code into my C# application.
Actually, within the debugger windows, I can't recognize any human-readable reference to the calling process, but the function is working.
So, for whoever may be interested, the following code is my C# 4 equivalent:
public static class DebugHelper
static extern bool IsDebuggerPresent();
static extern void DebugBreak();
public static bool AttachCurrentProcessToDebugger()
var sExePath = Path.Combine(Environment.SystemDirectory,
var process = Process.Start(sExePath, " -p " +
if (process.ExitCode != 0)
for (int i = 0; i < 5 * 60; i++)
catch (Exception ex)
var sExMessage = (ex.InnerException != null ?
ex.InnerException.Message + "; " : string.Empty)
+ ((ex.TargetSite != null) ? ex.TargetSite.ToString() : string.Empty);
Debug.Print(ex.GetType().Name + ": " + sExMessage + ex.StackTrace);
I am currently busy in the apparel industry developing software for cutting machines.
Over the past 15 or more years I did work in this field, initially as a technician.
After a ZX Spectrum lit my path in the 80s, I played with many technologies, ranging from DOS to Windows, evolving my interests from a school matter into an hobby, then a passion and finally into a full-time job.
Since the 90s I engaged with Basic, Pascal, Assembly, Batch files, C, C++, Visual-Basic, Java(script), VBScript, T-SQL, HTML, ASP, FoxPro, C#, always trying to grasp any available language tool (the last being Generics, Linq, IL, Expression trees).
I can claim experience for many kind of contexts, mainly DB, PM and CAD/CAM.
I'm information hungry and always try to improve my skills.
Apart from High school graduation, I have no specific certificate or title, but I can count on an enough sharp know-how (at least within the fields I'm not worry to step into).