1

Sorry if this is a duplicate, and from what I see it's not possible. But in any case is it possible to attach source for C# with windows debugger with correct symbols? I know we can use !name2ee for putting breakpoints on different functions, but is there a way to actually step through C# code like vb or C++ ? Or are there are alternatives to achieve the same?

4
  • I assume this is on a program you don't have the source to? Mar 11, 2014 at 17:16
  • I do have the source, but not able to attach it when debugging, I'm trying to troubleshoot a client issue. Did I misunderstand something here?
    – Vishal
    Mar 11, 2014 at 17:17
  • Why are you “not able to attach it when debugging”? Solve that first. Mar 11, 2014 at 17:19
  • I have tried it multiple times, have put the correct symbols and source. So, I was not sure if it was possible through the debugger for C#, i have done it correctly for vb and c++ files.
    – Vishal
    Mar 11, 2014 at 17:43

3 Answers 3

3

Unforturnately not possible with Windbg (or ntsd or cdb). Please see this old thread from the old microsoft.public.windbg news group back in 2008 with subject line "No CLR support in the latest debugger release". A Microsoft employee talks about the history and reasons for this and interestingly how a version of windbg slipped out accidentally that actually had this capability (and then later removed). Here's the link: https://groups.google.com/forum/#!topic/microsoft.public.windbg/A1MKBkM3L2Y

0
3

There is a command for loading the symbols, but I do not remember what it is. As I remember you need both the pdb and the source to get it to work.

If you have the code and want to step through why not use Visual Studios? You can download the express version for free. Also, Visual Studio's will allow you to attach to an already running process if you need.

1
  • Well, I guess I could. I was hoping just the symbols,source combined with the debugger will do the trick. As, I mentioned I have done it lot of times for VB and C++ code, never worked for C# somehow though.
    – Vishal
    Mar 11, 2014 at 19:41
1

Not as convenient as the unmanaged source code stepping, but maybe ok.

.symfix x:\symbols
.sympath+ x:\mypdbs
.srcpath x:\mysource
.reload
.loadby sos mscorwks;.loadby sos clr
.load sosex; *** Download SOSEX, use full path if necessary

Then open source code, File/Open Source File (Ctrl+O).

!mbp MySourceFile.cs 77; *** 77 is the line number
g

Wait until the breakpoint is hit, then try

!mt; *** managed step into
!mgu; *** managed go up
1
  • Any way to look at local vars values, like a watch, when the breakpoint is hit? In any case, I do appreciate your suggestions.
    – Vishal
    Mar 12, 2014 at 0:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.