Share via


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

Comments

  • Anonymous
    May 02, 2010
    I am keen to use MultipleMessagesPerPoll technology in our project but the below problem will prevent us from being able to implement. When using PollingDuplex with PollingDuplexMode.MultipleMessagesPerPoll, you might observe that messages from the server to the client arrive in 16/32KB batches. The benefit of using chunked messaging for real time applications is reduced as the message size is usually under 32KB. Is this a problem that will be fixed in up coming releases. If so does anyone know when? Any advice/help is greatly appreciated.   Thanks

  • Anonymous
    June 18, 2010
    I'm pretty sure this default behavior ruins the multiple message model.  What a terrible sacrifice to make to meet a schedule :'(

  • Anonymous
    September 16, 2010
    The comment has been removed

  • Anonymous
    January 27, 2011
    sir,  How to use the session mode in wcf with silverlight.I have come to know that session mode is not supported with basic http binding.and silverlight is only suporting the basic http binding.so how can i use the session mode in wcf with silverlight. Thanks in advance Regards, Raj

  • Anonymous
    February 18, 2011
    How do you instruct Silvelight to use Specif Proxy Server Setting, when calling Web Service from Client that is behine Firewall.

  • Anonymous
    June 16, 2011
    Are there any examples as to how to create a custom binding containing a pollingDupex binding element?