Error Handling In Silverlight 4.0
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. Web Development WCF RIA Services Silverlight Clients Silverlight Clients Error Handling on the Client Error Handling on the Client Error Handling on the Client Client Code Generation DomainContext and Operations DomainDataSource Error Handling on the Client Customizing Generated Code TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. Error Handling on the Client WCF RIA Services [WCF RIA Services Version 1 Service Pack 2 is compatible with either .NET framework 4 or .NET Framework 4.5, and with either Silverlight 4 or Silverlight 5.] This topic describes how you typically want to handle errors and take certain steps in response to the errors that you retrieve or modify data from a client. With WCF RIA Services, you handle errors by providing a callback method for data operations and checking for errors in that callback method. Using callback methods is necessary because calls to data operations are asynchronous and therefore any exceptions are thrown asynchronously. By default, an exception is thrown for any errors in domain operations. RIA Services provides ways for you to handle the errors and specify that the framework not throw an exception. Error Handling When Loading Data When loading data from a query method, you can either handle the error or choose to ignore the error. Specifically, you choose from the following options: Use a Load method that has a parameter for a callback method. In the callback method, handle the error and call the MarkErrorAsHandled method to indicate that the exception is not thrown. Use a Load method that has a boolean parameter named throwOnError. Set throwOnError to false when you call the Load method to indicate that you do not want an exception thrown for query errors. Use the Load method which does not have a parameter for a callback method or a boolean parameter. Any errors when running the query will result in an unhandled exception. The following example shows how to load data from a query and specify a callback method that checks for errors from the load operation. C#VB Copy private CustomerDomainContext _customerContext = new CustomerDomainContext(
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. Networking and Web Services Accessing Web Services in Silverlight Building and Accessing Services Using Proxies Building and Accessing Services Using Proxies Creating and Handling Faults in Silverlight Creating and Handling Faults in Silverlight Creating and Handling https://msdn.microsoft.com/en-us/library/ee807307(v=vs.91).aspx Faults in Silverlight How to: Build a Service for Silverlight Clients How to: Access a Service from Silverlight Configuring Web Service Usage in Silverlight Clients Accessing SOAP Services Accessing ASP.NET AJAX Services Debugging Services for Silverlight Applications Creating and Handling Faults in Silverlight Using SLsvcUtil.exe to Access a Service How to: Create and Access a WCF Service with the Channel https://msdn.microsoft.com/en-us/library/ee844556(v=vs.95).aspx Model TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. Creating and Handling Faults in Silverlight Silverlight Silverlight version 4 enables support for the Windows Communication Foundation (WCF) SOAP fault programming model, which allows the service to communicate error conditions to the client. In previous versions of Silverlight, if an error occurred on the service, it would register as an HTTP 500 response code and details about the error would not be accessible to the Silverlight client. Exceptions on the service are converted into SOAP faults before being sent by the service, and then they are converted from SOAP faults back into fault exceptions after they are received by the Silverlight client. The fault message contains a standard set of properties and an extensible detail object, whose content is controlled by the service. Depending on the contents of the detail object, a fault can be either defined or undefined. Undeclared faults are useful when debugging a service. T
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference https://msdn.microsoft.com/en-us/library/bb397417.aspx Dev centers Retired content Samples We’re sorry. The content you requested has http://stackoverflow.com/questions/579007/what-is-the-best-practice-for-exception-handling-in-silverlight been removed. You’ll be auto redirected in 1 second. MSDN Library MSDN Library MSDN Library MSDN Library Design Tools Development Tools and Languages Mobile and Embedded Development .NET Development Office development Online Services Open Specifications patterns & practices Servers and Enterprise Development Speech Technologies Web Development Windows Desktop App Development error handling TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not being maintained. Complete Example for Error Handlers Other Versions Visual Studio 2010 .NET Framework 4 Visual Studio 2008 This code example includes elements for both page-level and application-level exception handling. Code Example Files The example error handling in consists of the following files: Web.config Global.asax Default.aspx ExceptionUtility (to be put in the App_Code folder) GenericErrorPage.aspx HttpErrorPage.aspx Http404ErrorPage.aspx DefaultRedirectErrorPage.aspx Web.config The following example shows the Web.config file. The customErrors section specifies how to handle errors that occur with file types that are mapped to ASP.NET, such as .aspx, .asmx, and .ashx files. (In IIS 6.0 and in IIS 7.0 in classic mode, static content files such as .html and .jpg files are not mapped to ASP.NET.) The settings in the example customErrors section cause any unhandled HTTP 404 (file not found) errors to be directed to the Http404ErrorPage.aspx file. These HTTP 404 errors would occur if a request were made for an .aspx file, .asmx file, and so on and if the requested file did not exist. All other unhandled errors in ASP.NET files are directed to the DefaultRedirectErrorPage.aspx file. If static content files are not handled by ASP.NET, a request for a nonexistent .html or .jpg file does not cause a redirect to the Http404ErrorPage.aspx file. If you want ASP.NET to handle requests for all file types, you can configure IIS
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up What is the best practice for exception handling in silverlight? up vote 12 down vote favorite 5 In ASP.NET, I usually log exceptions at server-side, In windows forms I can either log exceptions server-side or write to a log file on the client. Silverlight seems to fit somewhere in between. I wanted to know what everyone else is doing to handle their Silverlight exceptions and I was curious if any best practices have emerged for this yet. silverlight exception-handling share|improve this question edited Apr 27 '12 at 6:41 R76 380525 asked Feb 23 '09 at 19:32 Jacob Adams 3,20821638 add a comment| 5 Answers 5 active oldest votes up vote 5 down vote accepted For real logging that you could store & track, you will need to do it on the server, since you can't be guaranteed anything on the client will be persisted. I would suggest exposing a "LogEvent(..)" method on a server side web service (maybe you already have one) which would then do the same kind of logging you do in ASP.net Here's a video about basic web service calls in Silverlight if you haven't done that yet http://silverlight.net/learn/learnvideo.aspx?video=66723 I'm not sure about any logging best practices though, my first guess would be to do the best practicies for logging in a web sevice on the server and expose that to the client. Hope this helps! share|improve this answer answered Feb 23 '09 at 21:07 TJB 9,83022139 add a comment| up vote 4 down vote I would say that Silverlight fits much better to ASP.NET side of the model. You have server which serves web page. An object (Silverlight app) on the page pings data service to fetch data and display it. All data access happens on the server side and it does not matter if data is used to create ASP.NET pages on the server or sent raw to the RIA for display. I do log any failures in data service on server side (event log works fine) and do not allow any exception to pass to WCF. When client does not receive expected data (it gets null collection or something similar), it display generic data access error to the user. We may need to extend that soon to pass a bit more informati