About Me

My photo
Northglenn, Colorado, United States
I'm primarily a BI Developer on the Microsoft stack. I do sometimes touch upon other Microsoft stacks ( web development, application development, and sql server development).
Showing posts with label silverlight. Show all posts
Showing posts with label silverlight. Show all posts

Friday, October 14, 2011

WCF & Silverlight max buffer size issue

Ran into these problems a few times with the WCF errors, in which the buffer size was the issue:
  • “The remote server returned an error: NotFound”
  • "Unable to read data from the transport connection: The connection was closed"
  • "The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element."
This would be an easy solution if only dealing with the WCF. Since, we are using the WCF layer to pass data to/from the Silverlight layer the problem arises in two locations -- not one.

Over at Mehroz's Experiments (http://smehrozalam.wordpress.com/2009/01/29/retrieving-huge-amount-of-data-from-wcf-service-in-silverlight-application/) he goes into good detail on solving this problem.

So in the Silverlight's ServiceReferences.ClientConfig we increase the buffer size.

Code Snippet
 <binding name="BasicHttpBinding_IScientificDataService"   closeTimeout="00:01:00"openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647" textEncoding="utf-8" transferMode="Buffered">
    <security mode="None"/>
binding>



In the WCF's Web.config, we needed to increase the maxBufferSize and maxReceivedMessageSize to a larger number



Code Snippet
  <system.serviceModel>
    <behaviors>
      <serviceBehaviors>
        <behavior>
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        behavior>
      serviceBehaviors>
    behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="false" />
  system.serviceModel>

Monday, August 29, 2011

One cause of Silverlight's White Screen of Death (WSOD)

We have this silverlight (4.0) website that would work for most, but a select few were only seeing a white screen. I tried running the website in different IE formats and even in firefox. The results were the same no matter what browsers were used. So we narrowed it down to something with the machine.

A white screen usually means that there is a silverlight error, which can be tough to trace/track down. In our case it came down to the issue that nested user controls cannot have static resources. Don't know how this applies to the machine level is beyond my comprehension.

So instead of this:
 <usercontrol.resources>
  <style targettype="sdk:DataGridColumnHeader" x:key="DataGridHeader">
      <setter Property="FontSize" Value="10"/>
      <setter Property="Padding" Value="3"/>
      <setter Property="Margin" Value="0"/>
 </style>
</usercontrol.resources>

We needed to put the style more inline:
<sdk:datagrid.columnheaderstyle>
   <style targettype="sdk:DataGridColumnHeader">
      <setter Property="FontSize" Value="10"/>
      <setter Property="Padding" Value="3"/>
      <setter Property="Margin" Value="0"/>
 </style>
</sdk:datagrid.columnheaderstyle>