I have a 3rd party library that is doing something internally that causes it to slow down greatly when the debugger is attached, even in release mode.
I have found 100's of explanations of how to detach the debugger manually in Visual Studio by going to Debug -> Detach process
. However I have yet to see anyone provide a example where a program could detach any attached debuggers to itself.
Basically is there an detach version of Debugger.Launch()?
According to Why can't you detach in interop-debugging?, the CLR doesn't support detaching of processes. However Visual Studio can do it. But the article is 5 years old so can you use DebugActiveProcessStop from the Windows Api via pinvoke?
BOOL WINAPI DebugActiveProcessStop(
__in DWORD dwProcessId
);
[DllImport("kernel32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool DebugActiveProcessStop([In] int Pid );
Edit: Just tried this: On the current process it gives Access Denied even if elevated.
Also is there anything in the CLR Managed Debugger (mdbg) Sample 2006 or 2011 version
Finally this article explains what you need to do to use ICorDebug::Detach and I suppose visual studio does do this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With