Using Trace Viewer for WCF Services

Just wanted to write about a great tool for assisting in debugging issues with a WCF service…and that’s Trace Viewer…some more info about Trace Viewer can found here.

Note: On my machine…running Win7 Ultimate, the exe (SvcTraceViewer.exe) was located in the C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin folder.

We couldn’t determine why a certain request to the service would not complete and Trace Viewer showed us the following:

There was an error while trying to serialize parameter http://tempuri.org/:GetDailyDetailsResult. The InnerException message was ‘Maximum number of items that can be serialized or deserialized in an object graph is ‘65536’. Change the object graph or increase the MaxItemsInObjectGraph quota. ‘. Please see InnerException for more details.

We increased the MaxItemsInObjectGraph by following the answer from Daniel Bergsten here

…and voila!…we get data back from the service now!

Here’s part of the relevant client config section.

<system.serviceModel>
    <client>
<endpoint address="http://localhost:3379/ServiceViewEvent.svc" behaviorConfiguration="ServiceViewEventBehavior"
        binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IServiceViewEvent"
        contract="ServiceReferenceViewEvent.IServiceViewEvent" name="WSHttpBinding_IServiceViewEvent">
        <identity>
          <dns value="localhost" />
        </identity>
      </endpoint>
</client>
<behaviors>
      <endpointBehaviors>
        <behavior name="ServiceViewEventBehavior">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>   
        </behavior>
      </endpointBehaviors>
</behaviors>
  </system.serviceModel>

Note the

<dataContractSerializer maxItemsInObjectGraph="2147483647"/>

section in both config files

Here’s part of the service config

<system.serviceModel>    
   <services>
      <service behaviorConfiguration="Umea.se.EventReactor.ServiceTier.ServiceViewEventBehavior"
       name="Umea.se.EventReactor.ServiceTier.ServiceViewEvent">
        <endpoint address="" binding="wsHttpBinding" contract="Umea.se.EventReactor.ServiceTier.IServiceViewEvent">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <behaviors>
      <serviceBehaviors>
        <behavior name="Umea.se.EventReactor.ServiceTier.ServiceViewEventBehavior">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="false" />
          <dataContractSerializer maxItemsInObjectGraph="2147483647" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
  </system.serviceModel>
Advertisements

About w4ik

software engineer...in the trenches
This entry was posted in ASP.Net, WCF and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s