Software Architecture – Debugging in Silverlight+WCF

Story of Debugging in Silverlight+WCF

Environment: Silverlight + WCF + NHibernate

Normally, you will get error as:

“silverlight [Async_ExceptionOccurred]\Arguments: \Debugging resource strings are unavailable.”

So solution is to install Silverlight Developer Runtime, which is different from normal silverlight run time. Basically Silverlight Developer Runtime provides better debugging/resources information, so highly suggested for Silverlight debugging.

So now the most common error thrown by WCF will be as:
“the remote server returned an error notfound”

Actually, it is general statement that something has gone wrong in WCF.
Possible reasons are be any of the following:
• Connection string is wrong for DB Connection.
• Any configuration file like Configuration.cfg.xml (Used for NHibernate) is missing.
• Any dependency file like LinFu.DynamicProxy.dll ( Used for NHibernate) is missing.
• Entities have circular references.
• Any other thing.

So it is very hard to figure out actual reason.

Beside Fiddler2, solution is to configure Service log for WCF Service.
Make sure to have following piece of tags in web.config of Sliverlight Web project.

          <binding name="Binding1"            
          maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
                <behavior name="">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                  <dataContractSerializer maxItemsInObjectGraph="500000" />
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />

          <add name="WcfListener"   
                  initializeData="d:\logs\wcfLog.svclog"  />   
       <!-- switchValue attribute has no impact on MessageLogging -->   
      <source name="System.ServiceModel.MessageLogging">  
              <add name="WcfListener" />  
        <source name="System.ServiceModel"  
                        switchValue="Warning, ActivityTracing"  
                      propagateActivity="true" >  
           <add name="WcfListener" />  

This configuration will create a log at d:\logs\wcfLog.svclog. It is a very messy log file, so WCF/SVC log viewer is required to read and analyzed the log data.
Install the WCF/SVC log viewer using web installation of Windows SDK
from following location. As size of SDK is very big(In GBs), so you can install selected features.

The Service Trace Viewer supports three file types:
• WCF Tracing File (.svcLog)
• Event Tracing File (.etl)
• Crimson Tracing File
Service Trace Viewer enables you to open any supported trace file, add and integrate additional trace files, or open and merge a group of trace files simultaneously.

The Service Trace Viewer provides the following different views. They are displayed as tabs on the left pane of the Viewer, and can also be accessed from the View menu.
• Activity View
• Project View
• Message View
• Graph View

Trace for exception will look like as:

On Clicking the red colored exception, details will be displayed in the below panel as:

Graph view of trace will look like as:



Leave a Reply

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

You are commenting using your 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

%d bloggers like this: