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.

<system.serviceModel>
	<diagnostics>  
		<messageLogging   
  		logEntireMessage="true"   
             logMalformedMessages="false"  
             logMessagesAtServiceLevel="true"   
             logMessagesAtTransportLevel="false"  
             maxMessagesToLog="3000"  
            maxSizeOfMessageToLog="2000"/>  
      </diagnostics> 
      <bindings>
        <basicHttpBinding>
          <binding name="Binding1"            
          maxBufferSize="2147483647" maxReceivedMessageSize="2147483647"/>
        </basicHttpBinding>
      </bindings>
      <behaviors>
            <serviceBehaviors>
                <behavior name="">
                    <serviceMetadata httpGetEnabled="true" />
                    <serviceDebug includeExceptionDetailInFaults="true" />
                  <dataContractSerializer maxItemsInObjectGraph="500000" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
        <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true" />
    </system.serviceModel>


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

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.

http://www.microsoft.com/downloads/details.aspx?FamilyId=0BAF2B35-C656-4969-ACE8-E4C0C0716ADB&displaylang=en

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:

Reference:
http://msdn.microsoft.com/en-us/library/ms732023.aspx

Advertisements

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

%d bloggers like this: