views:

23

answers:

2

One of the awesome things I remember in Visual Basic 6 from years ago that you could just load up an ActiveX exe project into the IDE, set a breakpoint, press Run and whenever someone (either an EXE or a project in a different IDE) called that DLL, your breakpoint would hit.

Is something like this possible with Visual Studio 2008? Can I load up a WinForms project into one IDE and a Class Library project into another IDE and have the WinForms project call the Class Library project?

+1  A: 

You can:

1) Add the project with the DLL to the solution with the EXE (this not quite what you're asking).

2) You can attach the IDE with the DLL project to the process running the EXE from Debug -> Attach to process. I never tried to attach two debuggers to the same process at the same time though.

Mau
+2  A: 

In VS you cannot attach two debuggers to the same process (it is possible to attach VS and WinDbg to the same process, but not in the default manner).

Point is, you don't have to use two debuggers or include the auxiliary project in your solution. Immediately after the dll load you'd be able to step through it and set breakpoints in it as if this was the solution you just compiled - all you need is the dll's debug symbols (pdb). Typically the dll load time is at process launch - but if it is loaded dynamically you might want to break immediately after the LoadLibrary call and only then set breakpoints in the dll. You can set the breakpoints in advance, but you'd still have to break somewhere after the dll load to enable the breakpoints to be translated into instruction addresses.

[Edit:] This does (I hope) answer the question as you put it, but it would not reproduce the VB experience you describe. AFAIK there is no way to set breakpoints in a library that would be applied to every process that loads that library. The closest I can think of is for you to set a MessageBox displaying the process ID in the library initialization routine (essentially DllMain), then manually attach a debugger to that process and set breakpoints as desired.

Ofek Shilon