
 June 21, 2019 11:42 by 
 Peter
 PeterIn this post I'll describe the way to handle the exceptions in Silverlight.  Whereas running the Silverlight application, if any exception happens  it'll attend Silverlight.js and show within the internet explorer as a  javascript error. Within the debugging purpose of read typically it's  cumbersome to see wherever truly the exception happened.

 LogWindow.xaml
 This is an easy user control that has an easy textbox:
 <TextBox 
 AcceptsReturn="True" 
 TextAlignment="Left" 
 TextWrapping="NoWrap"
 VerticalScrollBarVisibility="Visible" 
 x:Name="logText" 
 FontFamily="Courier New" 
 FontSize="12" IsReadOnly="True" HorizontalScrollBarVisibility="Auto" />
Logger.cs
This  class are used to print the exception and notice the stacktrace. it's  an enum for the exception types viz. DEBUG,INFO,WARN,ERROR and  FATAL.This class contains an easy delegate to add text to the log  window. The static property _instance is about by the LogWindow.xaml.cs go in the load event as:
 Logger._instance = logText;
So  that it will print whatever exception happenes in your application. The  LogException methodology expects exception object because the parameter  and find the exception information using the StackFrame class.
StackFrame frame = new StackFrame(true);
 callerSignature =  string.Format("@{0}:{1}:{2}", frame.GetMethod(), frame.GetFileName(), frame.GetFileLineNumber());
 
To use this method in your catch block you just simply need to call the static method as:
 Catch(Exception ex)
 {
 Logger.LogException(ex);
 }
 Hope this tutorial works for you!