Some known WCF issues in Silverlight 4

When shipping a product, there are always a handful of painful issues that we unfortunately cannot fix due to schedule pressure. One thing we can do is blog about these issues early and provide workarounds, so customers don’t have to spend countless hours debugging.

Here is the list of known issues in the WCF stack.

NetTcp

  • Problem: When using the “Add Service Reference” command in Visual Studio to generate a proxy to a NetTcp service, you might see a dialog box with the message “The Uri prefix is not recognized.” Workaround: This dialog box can safely be dismissed. The proxy and .clientConfig file get generated correctly.
  • Problem: When using a service configured with NetTcp binding, Silverlight does not honor TCP policy served by the server at port 943. Workaround: NetTcp in Silverlight requires that sockets policy be hosted over HTTP in a clientaccesspolicy.xml file. You cannot switch to hosting policy over TCP at port 943. That choice is available when using Socket directly, but it is not available when using WCF with a NetTcp service.

PollingDuplex

  • Problem: The Add Service Reference” command in Visual Studio will not generate configuration information in the .clientConfig file if using a PollingDuplex service. Workaround: The command will correctly generate a proxy. One of the proxy constructors takes a Binding and an EndpointAddress, which you can use instead of configuration. If you want to use configuration, the slsvcutil tool will generate configuration for PollingDuplex services. Note that the .clientConfig file generated by slsvcutil for PollingDuplex services may cause the “Add Service Reference” command to stop working if used from within Visual Studio.
  • Problem: When using PollingDuplex with PollingDuplexMode.MultipleMessagesPerPoll, you might observe that messages from the server to the client arrive in 16/32KB batches. Workaround: WCF services have a built-in behavior that causes them to buffer in 16KB chunks when self-hosted and 32KB chunks when IIS-hosted. There is no workaround for this behavior.
  • Problem: When using Web.config on the service to instantiate <pollingDuplexHttpBinding>, any nested <readerQuotas> element is not respected. Workaround: Instead of using <pollingDuplexHttpBinding>, use a <customBinding> containing a <pollingDuplex> element. Then instead of setting the values on <readerQuotas>, set the same values on the <textMessageEncoding> or <binaryMessageEncoding> element.
  • Problem: If ServerPollTimeout is larger than ClientPollTimeout, messages sent from the server to the client may be lost. Workaround: Always set ClientPollTimeout larger than ServerPollTimeout.
  • Problem: When using PollingDuplex with PollingDuplexMode.MultipleMessagesPerPoll on a custom binding with a security binding element, the security binding element cannot be placed after the PollingDuplex binding element. Workaround: Always put the security binding element before the PollingDuplex binding element in the custom binding elements.

Other

  • Problem: Silverlight 4 allows you to specify a relative EndpointAddress either in code or configuration. If you instantiate a proxy with a relative address on a worker thread, you will get a UnauthorizedAccessException about invalid cross-thread access. Workaround: Instantiate the proxy on the UI thread, then you can use the proxy on a worker thread.
  • Problem: If a relative EndpointAddress is specified in .clientConfig, that might cause the “Add Service Reference” feature in Visual Studio to stop working. Only specify a relative address once you are done adding service references to the project.
  • Problem: When using slsvcutil to generate a proxy to a service using a class that implements ISerializable, the generated proxy will cause the values to not be serialized correctly. Workaround: Manually edit the generated proxy. Find instances of  [System.Xml.Serialization.XmlAnyElementAttribute(Namespace="")] and remove the Namespace attribute if it is set to “”.

Thanks,

-Yavor Georgiev
Program Manager, WCF