Reputation: 135
An architecture which I have to deal with is quite complicated: a native C++ Windows Service creates an out-of-process COM object (native C++, CoCreateInstance with context = CLSCTX_LOCAL_SERVER) which dynamically loads (AfxLoadLibrary) my C# DLL.
I would like to debug my DLL when I click Debug -> Start Debugging.
I know that I can debug it when I attach to COM object process using Debug -> Attach to process and I can use System.Diagnostics.Debugger.Launch()
in my DLL code if I need to debug startup but none of this options work automatically.
I also tried this technique: https://learn.microsoft.com/en-us/previous-versions/visualstudio/visual-studio-2010/a329t4ed(v=vs.100) but the COM process runs as a SYSTEM user so that I cannot select my existing Visual Studio Solution with my C# project to use as a debugger, I can only start a new instance with only EXE loaded.
I tried "Start external program" too but what I need to start is a service which is not the process I want to debug, because my DLL runs in another process (the COM-one). So, debugging stops as soon as service is started (because I run it with a script, maybe this is a problem).
Upvotes: 3
Views: 870
Reputation: 3874
I don't see an option to automate it entirely with standard Visual Studio features. So I would propose you to write a simple Visual Studio extension. Just use the template and add a button to the menu or to some custom window, which on click will:
I'm not sure if it will help, but you may check my simple VS extension. I wrote it some time ago to configure symbols in the debugger.
Upvotes: 1