20

I have a WCF test service and a test client in the same solution. The service is configured to run on localhost (Ie, "http://localhost:8731/Design_Time_Addresses/MyService/Service") I run the client app and it correctly invokes the service and gets back the correct answer. I've verified via logs that it's definitely running the service that's local to my machine. However, I can't debug into the service when running the client. WCF is supposed to allow just stepping through, but no breakpoints on the service get hit, and stepping in to the service call doesn't work either. Has anyone ever seen this?

I've checked all the obvious stuff like "is the PDB file being generated?" -- yes, it is. If I run the service project by itself, then hit it with some test client, breakpoints get hit correctly. So debugging on the service works. I can even explicitly "attach to remote process" and debug the service that way. But WCF will not automatically step from the client to the service.

3
  • how you host your WCF service? Windows Service? IIS? Aug 20, 2009 at 16:08
  • No, it's running locally inside the same solution through Visual Studio. IE, localhost:8731/Design_Time_Addresses/MyService/Service Aug 20, 2009 at 16:11
  • Make sure you're using the right endpoint when you set up your proxy. I spent an hour only to realize I was pointing to an endpoint that I don't have in development.
    – Trevor
    Feb 5, 2014 at 2:00

9 Answers 9

23

I've had this happen as well. Curiously it seems to happen after I make changes to the build configuration (from x64 to x86). Here's how I've been able to fix it:

  1. Right-click the solution, select Properties.
  2. Under "Startup Project" switch from "Single startup project" to "Multiple startup projects".
  3. Set Action to "Start" for the WCF project.

Even though I'm hosting the project in the local IIS server (not the VS Development Server) this solves it, which is a little puzzling. I suspect that setting a project to "Start" also causes VS to attach to the process for debugging.

http://msdn.microsoft.com/en-us/library/bb157685.aspx

5
  • Only took me 4 hours to find this post. You rule! Sep 7, 2011 at 21:54
  • I have similar problems with the debugger, but changing the x86/x64 configuration does not work on my machine. Client and server are both running on 32-Bit, but still I cannot step into the service's code
    – Knasterbax
    Jan 23, 2013 at 9:15
  • 1
    This didn't fix it for me :/
    – shadowsora
    Sep 26, 2018 at 12:15
  • I tried all the solutions on this page but nothing worked. Finally I created a new console application with a new name and copied all my existing files there. I was then able to debug without using System.Diagnostics.Debugger.Break(). The problem had started happening after I changed the project type for WCF service from class library to console application. I wanted to run the host within the service itself. Then I restored my changes over the original project.
    – Ashok Garg
    Nov 14, 2021 at 18:03
  • @Ashkok is this a comment about this answer, or are you proposing a different answer?
    – msulis
    Nov 15, 2021 at 19:49
4

For Visual Studio multi-configurations:

In the Property Pages of your solution, ensure that the "Configuration" for your web-service is set for "Debug", not "Release".

3

Are you using the automatic WCF service hosting feature in Visual Studio? You can check this by opening the project properties of your WCF service project and navigating to the WCF Options tab. Is the Start WCF Service Host when debugging another project in the same solution checkbox checked? If it is, then this explains the problem.

What's happening is that when you run your client, a separate process is created to automatically host your WCF service. Because it is a separate process, you will not be able to "step into" it when debugging your client. You'll have to run two separate debug sessions, one for your service and one for your client.

An easy way to do this is to put a call to System.Diagnostics.Debugger.Break() in the startup logic for your service. When your service is automatically started by the WCF service host, you'll be prompted to debug it, allowing you to open a second instance of Visual Studio for its debug session.

1
  • I think this would only apply if the WCF service is self-hosted, which would mean NOT inside IIS, the VS Dev server, or the WCF Service Host. Or more simply, what the OP is asking about usually works "out of the box" in a solution with a WCF project - you can just step into it.
    – msulis
    Sep 7, 2010 at 6:22
1

Also when using VS debug and attaching it to the w3wp.exe process and you have specific port bindings other than http:80:* you must have the debug > web in VS set to the site and port http is running on.

1

Yes, I got the same problem, WCF uses another processs.

At last, I found a way, i start a new instance(debug->start a new instance) of WCF service first, then start the client side, the breakpoints in the WCF service hits!

1

One other reason for not stepping into WCF service may be the size of your data that is passed to the WCF methods.

For ex., I was passing an array of dobules of size 1000, and I was getting a bad request error (400) with seeing how the method is run. I made the size 500 and now it debugs the WCF.

1
  • 1
    This made me think "the message I'm sending is also quit big" (I'm sending binary files to the service). Reduced the size of the message and it fixed the problem ! Sep 27, 2016 at 6:27
1

In my case, I had published it using Release configuration. You need to select Debug here.

enter image description here

0

I had similar problem. WCF hosted by WCF Service Host, requests tested by WCF Test Client. My problem was caused by space in build configuration name. As soon as I used configuration name without spaces, debbuging worked.

I guess the real problem was the build output folder ending with folder named by the configuration name.

0

@msulis - yes, thanks, this remedied it for me. I had also changed recently, the target CPU from any to x86. I couldn't reply directly to you message for some reason so apologize if this comes up as an "answer".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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