/////////////////////////////////////////////////////////////////////// private static bool Attach( ref string error ) { try { if (VersionOps.IsWindowsOperatingSystem()) { int processId = UnsafeNativeMethods.ATTACH_PARENT_PROCESS; if (UnsafeNativeMethods.AttachConsole(processId)) { return(true); } else { error = "failed to attach console"; } } else { error = "not implemented"; } } catch (Exception e) { error = e.ToString(); } return(false); }