1

I am trying to debug my DLL Class Library on Windows, but I am not able to get the debugger to stop in the source code.

Environment: Windows 10 Pro x64, Visual Studio Premium 2013 Update 5. Project is a .NET 4.5 Class Library. The executable is actually instantiated by another .exe before it calls my .dll. (I don't have source access to either of these .exes.) The .dll is in the same dir as its calling .exe, but that is not the Class Library project directory. I know my .dll code is executing, as I create new windows in my code, which are opening.

I have tried Debug->Attach to Process... in VS2013, and I connect to the calling .exe process, but the breakpoint I have set in my code never is hit, despite that code definitely being called. What am I missing here?


EDIT: This is not a duplicate of another question:
  • Not getting any error message
  • Not intermittently working
  • The assembly is confirmed as being loaded and executed
Community
  • 1
  • 1
Conrad
  • 2,197
  • 28
  • 53
  • you have not supplied compile information about your dll that you having trouble with. What configuration you've used to build it and what settings are on that configuration – T.S. Apr 01 '17 at 01:18
  • @T.S. I will get back to you on Monday with the specifics, when I'm back in the office, but it is an otherwise vanilla Debug config. – Conrad Apr 01 '17 at 01:22
  • Possible duplicate of [Fixing "The breakpoint will not currently be hit. No symbols have been loaded for this document."](http://stackoverflow.com/questions/2155930/fixing-the-breakpoint-will-not-currently-be-hit-no-symbols-have-been-loaded-fo) – qxg Apr 01 '17 at 03:23
  • @Conrad,Could you share us the detailed steps about how you debug your dll from the .exe? Do you get any messages in the Output window or the debug Modules window? Do you have the pdb file for your dll ? – Jack Zhai Apr 03 '17 at 08:19
  • @qxg It's not a duplicate. – Conrad Apr 03 '17 at 14:50

2 Answers2

0

Your assembly might be compiled for release or compiled without any debug info. If you do things correctly, you should be able to debug by attaching to process. Another thing that can be, your code executes before you can attach to it. sometimes, especially in services, you put thread.Sleep into code, so this buys you some time to attach.

T.S.
  • 18,195
  • 11
  • 58
  • 78
  • My project is using a standard VS Debug config. I am attaching to the running process before my code executes. – Conrad Apr 01 '17 at 00:02
0

The issue turned out to be VS was not correctly figuring out what type of code to debug. In the Attach to Process window, I had to switch from Automatic to manually specify debugging Managed (v4.5, v4.0) code type in the Attach to: option, before attaching to the parent .exe process. I could then step through my source. (As it turns out, copying the .pdb file was not required - VS still uses the version of that file in the original project Debug directory.)

Conrad
  • 2,197
  • 28
  • 53