1

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?

Aaron Anodide
  • 16,906
  • 15
  • 62
  • 121

2 Answers2

1

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
  • 33,626
  • 4
  • 73
  • 96
  • my assembly is in a separate compiled dll. is that what you mean by plugin? – Aaron Anodide Oct 13 '10 at 23:09
  • 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 Oct 13 '10 at 23:39
  • 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. – Aaron Anodide Oct 14 '10 at 15:46
0

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
  • 3,749
  • 1
  • 30
  • 54