0

I develop a C# program that allows the user to enter C# code for extensibility. This code shall be developed in Visual Studio Express and will be compiled into a DLL which is then used in the main program. This part is fine.

To aid the user in debugging the supplied code, I'd like to add the possibility to activate breakpoints in the user DLL, i.e. use the ones that are set in the solution.

How can I achieve this in the final product, i.e. the program is not launched from Visual studio?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Onur
  • 5,017
  • 5
  • 38
  • 54
  • Add Debugger.Break(); statement whereever you want to add breakpoint. Whenever control hits this breakpoint it will open Visual Studio environment. – Pankaj Kapare May 18 '15 at 16:48
  • 1
    The user already has VS, that's all he needs. He'll need to use Project + Properties, Debug tab, Start External Program radio button and select your program. Pressing F5 starts your program, the breakpoints turn solid as soon as your program loads the DLL. – Hans Passant May 18 '15 at 17:40
  • @HansPassant This should work. Is there a way to do it from the running main assembly? I thought of a button "activate breakpoints" that would somehow attach the visual studio to the already loaded assembly. – Onur May 19 '15 at 07:13
  • @PankajKapare I would like to enable the feature only on demand not break always, (un)comment the statements or recompile the project using another preprocessor statement etc. – Onur May 19 '15 at 07:14
  • Two possible solutions are posted here: [https://stackoverflow.com/questions/13672751/how-to-debug-class-library-that-called-from-external-app](https://stackoverflow.com/questions/13672751/how-to-debug-class-library-that-called-from-external-app) It would be great to enable debugging from the main application, i.e. attach the Visual studio to the user DLL in the main program. – Onur May 19 '15 at 07:21

0 Answers0