I'm currently working on a solution which needs to use both Silverlight 3.0 and standard .NET applications as clients to a web service implemented with WCF. The portions of the web service consumed by the Silverlight client need duplex functionality, so I'm using the (still fairly new) PollingDuplexBindingElement on one end point of my service. However, PDBE is only supported by Silverlight, so I've added a second end-point to my service for other clients, which uses WSDualHttpBinding as the binding. These other clients don't actually need duplex, but because portions of the server-side contract require duplex, a standard simplex binding like WSHttpBinding won't work.
Because of the weird Silverlight WCF requirements (e.g., rewriting HTTP 500 fault responses to HTTP 200, etc.), I'm initializing my service through a custom ServiceFactory class, the key portions of which look like this:
protected override void InitializeRuntime()
{
// Add the WSDualHttpBinding.
// This should listen at http://<servername>/RoomService.svc/wsdual
WSDualHttpBinding wsDualBinding = new WSDualHttpBinding(WSDualHttpSecurityMode.None)
{
MessageEncoding = WSMessageEncoding.Text,
TextEncoding = new System.Text.UTF8Encoding()
};
this.AddServiceEndpoint(
typeof(IRoomService),
wsDualBinding,
"wsdual");
// Add the PollingDuplexBinding
// This should listen at http://<servername>/RoomService.svc
PollingDuplexBindingElement pollingDuplexBindingElement = new PollingDuplexBindingElement()
{
// I'm not sure that these values are the best. They're an initial guess.
ServerPollTimeout = TimeSpan.FromSeconds(90),
InactivityTimeout = TimeSpan.FromMinutes(30)
};
CustomBinding pollingDuplexBinding = new CustomBinding(
pollingDuplexBindingElement,
new BinaryMessageEncodingBindingElement(),
new HttpTransportBindingElement());
this.AddServiceEndpoint(
typeof(IRoomService),
pollingDuplexBinding,
"").Behaviors.Add(new SilverlightFaultBehavior());
// Add the MetaData Exchange binding.
this.AddServiceEndpoint(
typeof(IMetadataExchange),
MetadataExchangeBindings.CreateMexHttpBinding(),
"mex");
base.InitializeRuntime();
}
And (somewhat astonishingly) everything works. The Silverlight/PollingDuplex clients all get their neat-o callbacks (much, much nicer than SL 2.0!), and the .NET/WSDualHttp clients can all talk to the server just fine.
Except for one thing. When I try to debug the application, Visual Studio throws up the following dialog box when it hits the first simplex call over WSDualHttp:
"Unable to automatically debug 'MyCompany.Service'. The remote procedure could not be debugged. This usually indicates that debugging has not been enabled on the web server. See help for more information."
The error message isn't quite accurate. It turns out that you can do step-through debugging into the web service through any duplex (one-way) call, but not through any simplex (two-way) call.
Now, of course, I've checked to confirm that my web.config is setup appropriately, i.e., it has the following line in it:
<compilation debug="true">
I've been beating my head against this long enough that I've put together a fairly straightforward repro (available here) which demonstrates the issue. As best as I can tell, it shows up when you use WSDualHttpBinding within IIS, and then try to make standard simplex calls against that service.
My initial workaround was to split off the Duplex from the Simplex pieces of the service, at which point everything worked just fine -- but at the cost of duplicate object models on the clients, which was not ideal. So I've moved everything back to just one service, but it sure is a pain not to be able to debug anything.
Has anybody else run into this, or have any suggestions?
FWIW, I've posted more-or-less this same question on MSDN with no suggestions, and I've tried to open a bug with MS Connect, but again, no help yet from that quarter.
Any ideas?