Error message: Unable to automatically debug service
- I have a duplex web service (hosted in IIS/Casini) which needs to be called both from Silverlight and from regular .NET code. Consequently, it's listening on three different endpoints, with three different bindings: the new Silverlight PollingDuplexBindingElement, WSDualHttpBinding, and of course MexHttpBinding for exchanging metadata.
I'm using a service factory to create the service like so:
protected override void InitializeRuntime() { // Define the binding and set time-outs. PollingDuplexBindingElement pdbe = new PollingDuplexBindingElement();
// Add an endpoint for the given service contract.<br/> this.AddServiceEndpoint( typeof(IRoomService), new CustomBinding( pdbe, new BinaryMessageEncodingBindingElement(), new HttpTransportBindingElement()), "").Behaviors.Add(new SilverlightFaultBehavior()); // This should listen at http://<servername>/services/RoomService.svc/wsdual<br/> this.AddServiceEndpoint( typeof(IRoomService), new WSDualHttpBinding(WSDualHttpSecurityMode.Message), "wsdual");
this.AddServiceEndpoint( typeof(IMetadataExchange), MetadataExchangeBindings.CreateMexHttpBinding(), "mex");
base.InitializeRuntime(); }
Initially, I only had the PollingduplexBindingElement on the service, and everything worked fine. But then I added the WSDualHttpBinding, and although calls over both bindings seem to work correctly, when I debug the solution from within Visual Studio (using the built-in Cassini web server), I get the following error message after the first web service call:
"Unable to automatically debug 'SlideLinc.Service'. The remote procedure could not be debugged. This usually indicates that debugging has not been enabled on the server. See help for more information."
When this message shows up, breakpoints don't get hit, and Debug.WriteLine() messages don't appear in my Visual Studio output window.
The standard advice for this error message is to make sure that web.config has <compilation debug="true"> in it, which it does:
The gentleman experiencing a similar problem on this thread here ( http://social.msdn.microsoft.com/Forums/en-US/wcf/thread/fed739a7-d564-46c1-b2d5-603eb408895a ) turned out to have triggered the problem by calling the MEX portion of the service with an incorrect address. I'm not doing that, and I double-checked the values at which the endpoints are listening, and to which the calls are being made, and they all seem to be correct.<system.web><br/> <compilation debug="true"><br/> <assemblies><br/> <add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/><br/> <add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/><br/> </assemblies><br/> </compilation><br/> </system.web>
I've also seen some suggestions to run various flavors of " vsdiag_regwcf.exe -u ", but I'm not interested in making the message go away: I'm interested in actually debugging the service.
I looked through a service trace with the Microsoft Service Trace Viewer, but I wasn't able to spot any obvious errors.
It's not an issue with my Visual Studio configuration, as returning to the state of the code before I added the WSDualHttpBinding fixes the problem.
In other words, the problem appears to show up (for me, at least) when I have two different duplex endpoints bound to the same service.
Any thoughts or suggestions on how to tackle this?
Thanks in advance.
For what it's worth, I'm attaching the relevant portions of the web.config for my service:
<system.serviceModel> <!-- ks: aspNetCompatibility is required for sharing state between WCF and ASP.NET --> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> <bindings> </bindings> <extensions> <behaviorExtensions> <add name="silverlightFaults" type="SlideLinc.Service.SilverlightFaultBehavior, SlideLinc.Service, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"/> </behaviorExtensions> </extensions> <behaviors> <endpointBehaviors> <behavior name="SilverlightFaultBehavior"> <silverlightFaults /> </behavior> </endpointBehaviors> <serviceBehaviors> <behavior name="SlideLinc.Service.RoomServiceBehavior"> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="true" /> <dataContractSerializer maxItemsInObjectGraph="2147483646" /> </behavior> </serviceBehaviors> </behaviors> <services> <service name="SlideLinc.Service.RoomService" behaviorConfiguration="SlideLinc.Service.RoomServiceBehavior" /> </services> <diagnostics performanceCounters="All" wmiProviderEnabled="true"> <messageLogging logEntireMessage="true" logMalformedMessages="true" logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" maxMessagesToLog="100000"/> </diagnostics> </system.serviceModel>
Ken Smith
回答
- I don't know about Michael or anyone else, but yeah, I was using AspNetCompatibilityMode before I abandoned using IIS to host my service.
For what it's worth, MS acknowledged this one as a bug, and said that it would get fixed in VS 2010 Beta 2.
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=472536
Ken Smith- 回答としてマークKen Smith 2009年9月18日 18:53
すべての返信
- Since I never experienced this issue before, could you please send your test project to me at v-mazho at microsoft dot com for repro? BTW, which version of Visual Studio you are using?
Thanks
Another Paradigm Shift
http://shevaspace.blogspot.com - I apologize for taking so long to reply on this one. I ended up implementing a workaround by splitting off the duplex from the simplex services, and that took care of my immediate problem for a while. However, it also introduced a whole series of other architectural problems, so I want to migrate everything back to just one service (e.g., one .svc file). And in the process of moving everything back, I ran into this problem again.
A couple things to note:
- I'm using Visual Studio 2008 SP1, with Silverlight 3.0.
- If you call a duplex method first, you can debug the method call in question, but later method calls will trigger the error message.
- If you call a simplex method first, you'll get the error, and won't be able to debug anything.
I've created a pretty straightforward repro, and have put it out on http://wouldbetheologian.com/DuplexRepro.zip .
Ken
Ken Smith - Just bumping this up again. Anyone have any suggestions for troubleshooting this, or working around it?
Ken Smith - For what it's worth, I went ahead and filed a bug on this:
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=472536
Ken Smith - Just pinging this again to see if anyone has any suggestions. We're blocked on this one, unless I can figure out a workaround.
Ken Smith - I'd love to hear from someone at MS about this . . . it's a fairly clear error, it certainly seems to be a bug, and it's blocking us from moving forward. Any suggestions?
Ken Smith - I'm having a similar problem, though not involving duplex bindings. I get the same error message about not being able to debug the service. I've carefully gone through every change made to my web.config file and isolated it down to adding in the <security/> element to a custom binding.
Here's my configIf I comment out the security element that I've highlighted above, every thing works ok, but when I leave it in, then I get the error message.<system.serviceModel> <extensions> <behaviorExtensions> <add name="silverlightFaults" type="Behaviours.SilverlightFaultBehavior, Wcf.Behaviours, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" /> </behaviorExtensions> </extensions> <diagnostics> <messageLogging logMalformedMessages="false" logMessagesAtServiceLevel="false" logMessagesAtTransportLevel="false" /> </diagnostics> <services> <service behaviorConfiguration="CommonServiceBehaviour" name="Server.Services.ScenarioService"> <endpoint address="" binding="customBinding" bindingConfiguration="AuthorisedBinaryHttpsBinding" name="Http" contract="Server.Contracts.Services.IScenarioService" behaviorConfiguration="CommonEndpointBehaviour"/> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> <bindings> <customBinding> <binding name="AuthorisedBinaryHttpsBinding" receiveTimeout="00:03:00" sendTimeout="00:03:00"> <!-- Here's the problem element: --> <security authenticationMode="UserNameOverTransport"> </security> <binaryMessageEncoding> <readerQuotas maxDepth="100" maxStringContentLength="1000000" maxArrayLength="655360000" /> </binaryMessageEncoding> <httpsTransport /> </binding> <binding name="BinaryHttpsBinding"> <binaryMessageEncoding /> <httpsTransport /> </binding> </customBinding> </bindings> <behaviors> <serviceBehaviors> <behavior name="CommonServiceBehaviour"> <serviceAuthorization principalPermissionMode="UseAspNetRoles"/> <serviceCredentials> <userNameAuthentication userNamePasswordValidationMode="MembershipProvider" membershipProviderName="AdminSqlMembershipProvider"/> </serviceCredentials> <serviceMetadata httpGetEnabled="true" /> <serviceDebug includeExceptionDetailInFaults="${includeExceptionDetailInFaults}" /> <dataContractSerializer maxItemsInObjectGraph="2147483647" /> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="CommonEndpointBehaviour"> <silverlightFaults /> </behavior> </endpointBehaviors> </behaviors> </system.serviceModel>
I must say that my first thought was that the SilverlightFault behaviour was causing the problem (as that was obviously common between Ken's setup and mine), but I've tried removing that from the equation, and it makes no difference. - I managed to fix my problem. When I turned on tracing for WCF I discovered this error:
Security processor was unable to find a security header in the message. This might be because the message is an unsecured fault or because there is a binding mismatch between the communicating parties. This can occur if the service is configured for security and the client is not using security.
That pointed me to the binding setup on my client side, where I discovered I was using a binding without the requisite Security element. Since I'm using a custom binding, and configuring it through code, I had to do:Once that was sorted, the problem went away and I was able to debug correctly.var binding = new CustomBinding( binaryEncoding, SecurityBindingElement.CreateUserNameOverTransportBindingElement(), new HttpsTransportBindingElement { MaxReceivedMessageSize = MaxMessageSize, });
I don't know why this problem should prevent ASP.Net debugging - that sounds like a bug to me.
Hope that helps. - For what it's worth, my workaround was to move away from hosting the service in IIS. I don't really like hosting it in a normal Windows service during development, because debugging it is too complicated, so for now I've simply implemented it as a console application. But at least I can debug the service now.
Ken Smith - I'm getting the same annoying issue: WPF App --> WCF Service 1 --> WCF Service 2.
When the call from Service 1 returns, that's when the error pops up. WTF. :P I'm curious to know, are you using AspNetCompatibilityMode?
Christopher Scrosati, Software Design Engineer, WCF Silverlight, Microsoft Corp.- I don't know about Michael or anyone else, but yeah, I was using AspNetCompatibilityMode before I abandoned using IIS to host my service.
For what it's worth, MS acknowledged this one as a bug, and said that it would get fixed in VS 2010 Beta 2.
https://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=472536
Ken Smith- 回答としてマークKen Smith 2009年9月18日 18:53
I see you are using AspNetCompatibilityMode on the services, and we do have known interaction that affects pollingduplex. We are currently writing a document to inform developers how to use PollingDuplex in a AspNetCompatibilityMode environment.
In the meantime, could you try to set your pollingDuplex client to use the ClientHttpWebRequest stack on the Silverlight client? That might be the issue.
You would need to set this in your Silverlight app, before any call to that service:
WebRequest.RegisterPrefix("http://insertDomainToFilterHere", WebRequestCreator.ClientHttp);
Christopher Scrosati, Software Design Engineer, WCF Silverlight, Microsoft Corp.Is there any reference to AspNetCompatibilityMode in your code/config?
I am trying to trace see if there is correlation here.
Christopher Scrosati, Software Design Engineer, WCF Silverlight, Microsoft Corp.- I was not using AspNetCompatibility. Switching to net.tcp fixed the problem in this case. Luckily we're using that for our services.

