How to debug WCF programs

后端 未结 7 1248
执笔经年
执笔经年 2020-12-31 01:21

My code uses lots of WCF calls and when I try to debug it, it doesnt go to the service code itself. Is there a way to debug WCF code somehow?

7条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-31 01:44

    You need to attach the debugger to the process that your wcf service is running in.

    If in iis you need to attach to the corresponding w3p.exe process.

    If in a stand alone app or windows service, attach to the name of your exe.

    In Visual Studio, on the debugger menu, there is an "attach to process". Open the relevant code, set a breakpoint, and call the service causing that code path to execute.

    Outside of debugging, using .net tracing with switchable levels is a good way to get insight to what's going on. I typically setup sys internals debugview to color highlight errors and warnings and constantly have it running while running code or tests. Colored lines out of my peripheral vision while working finds issues.

提交回复
热议问题