There is an external workflow that executes C# scripts and is able to work with DLL files(my class library).
Is it possible to attach debug to my class library project so breakpoint will hit once this WF will call it?
Thanks
Right click on solution -> Add Existing Project -> then select the . csproj file of your external library (project B). Again in visual studio right click on (project A) -> Add -> Project Refference... -> and then add checkmark on your external library which you want to debug (project B).
Just use File/Open Project/Solution, select EXE file and Open it. Then select Debug/Start debugging. The other option is to run the EXE first and then Select Debug/Attach to process.
Yes, you can do this with Visual Studio. You have two options:
Open your DLL project.
On the properties for the project, go to the Debug tab.
Choose Start external program and give the path of the external program that will call your DLL, along with any command-line arguments you may need to supply, and the working directory if that's relevant.
Save the project.
Set breakpoints in your code where you want them.
Press F5 to start debugging. (At this point, your breakpoints will say that they won't be hit because the symbols aren't loaded. Don't worry about that for now.)
Do whatever you do to make the external application load your library and run your code.
Visual Studio will detect the module load, load the symbols, and stop on the breakpoint.
If you can't start the process but instead have to attach to a process that's already running, you can do that too:
(Side note: If you're using the "Express" edition of Visual Studio, I don't think it has this feature, but I'm not certain about that. It's easy enough to tell: You'll either have the menu item mentioned on Step 4 below or not.)
Make sure the process is running.
Open your DLL project.
Set your breakpoints, etc.
From the Debug menu, choose Attach to process...
In the resulting dialog box, find the process in the list, highlight it, and click Attach.
Visual Studio will go into debug mode. (At this point, your breakpoints will say that they won't be hit because the symbols aren't loaded. Don't worry about that for now.)
Do whatever you do to make the external process load and run your code.
Visual Studio will detect the module load in the external process, load your symbols, and stop on your breakpoint.
N.B. In both cases, if the external process loads your DLL from somewhere other than the bin/Debug
folder of your project, you must make sure you copy the DLL to that other location every time you build it (you can set that up to happen automatically in the project options). Otherwise, Visual Studio won't be able to detect that the DLL being loaded is the one you're trying to debug.
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