If I attach to a application's process and debug, then stop debugging, and recompile a dependent assembly, is it possible to add logic to my application which does an unload/re-load to that assembly such that I'll be able to re-attach to the process and debug again without re-starting?
+1
A:
I suppose technically it might be possible, if your code were written to load the assembly dynamically (like a plugin assembly), but even then it'd only work if no classes/resources from the assembly had been used. So, for all realistic purposes, no: what you launch is what you're running.
That said, what you're trying to attempt sounds pretty close to what edit-and-continue does in Visual Studio. Have you tried that? Why do you need to recompile the assembly in the first place?
Dan Puzey
2010-10-13 23:04:43
my assembly is in a separate compiled dll. is that what you mean by plugin?
Gabriel
2010-10-13 23:09:14
No - your DLL may be separately compiled, but if your C# application references it directly then you won't be able to unload it at runtime. But, if your code explicitly loads the DLL at runtime (using `Assembly.Load`, for example) then you could conceivably unload it and reload a different version - but you'd not be able to maintain instances of any classes from the DLL. What's the problem you're actually trying to solve, though?
Dan Puzey
2010-10-13 23:39:58
@Dan, the application I don't want to restart is a test harness with a GUI that doesn't persist any state. One of the integration services it exercises (from a separate DLL) calls out to a COM interop library which in turn invokes routines in a popular desktop accounting software that has configuration explicitly authorizing my test application to connect - however, and I suspect this is related to the way VS2010's debugger works, it fails to recognize the application and refuses connection in normal debug mode, but if I start it normally and connect to process, I'm good.
Gabriel
2010-10-14 15:46:14
A:
You could try Shadow Copy Cache. I know it from its use in NUnit, where you can change your test\tested code without restarting the NUnit GUI.
Amittai Shapira
2010-10-14 13:01:46