Silverlight error logging

gkneogkneo Posts: 5
edited December 7, 2010 10:30AM in SmartAssembly 5
Hi,

Aside from catching unhandled exceptions in my Silverlight 4.0 app (currently built using PRISM), I want to log errors on handled exceptions. I mean, in my Silverlight client, I would have:
try
{
doSomething();
}
catch (Exception e)
{
	LogError(e);
}

The method LogError will use SA to send a report to its web service. Is that currently possible using the SA's?

I have already done this within a .net 4.0 library referenced by the web site hosting the SL client. I have a static method "LogError(Exception ex)" which calls
SmartAssembly.ReportException.ExceptionReporting.Report(ex);

This library references SA's SDK library (SmartAssembly.ReportException.dll)

Regards,

Guillermo

Comments

  • HI, yes, I believe this is possible- you will need to use the SDK and, as you say, simply call the Report method directly.
  • Hi,
    I have only found the following method to use in my SL app:
    SmartAssembly.SmartExceptionsCore.UnhandledExceptionHandler.ReportException(Exception e, object[] obj)
    

    It is located in the SmartExceptionsCoreSilverlight.dll library.


    But this method doesn't work. I have used variations for the 2nd parameter and it always throws an exception:
    threw an exception of type 'System.TypeInitializationException'
        base {System.SystemException}: {System.TypeInitializationException: Se produjo una excepción en el inicializador de tipo de 'SmartAssembly.SmartExceptionsCore.UnhandledExceptionHandler'. ---> System.FormatException: No se puede reconocer la cadena como un tipo booleano válido.
       en System.Boolean.Parse(String value)
       en System.Convert.ToBoolean(String value)
       en SmartAssembly.SmartExceptionsCore.UnhandledExceptionHandler..cctor()
       --- Fin del seguimiento de la pila de excepciones internas ---}
        TypeName: "SmartAssembly.SmartExceptionsCore.UnhandledExceptionHandler"
    


    As I said before, I want to report handled exceptions. Is this is the right method to use?
  • iosubiosub Posts: 23 Bronze 1
    Hi

    I'm having the same problem..

    Is there a solution ?

    Thank you
  • Sorry for the delay. Here is the workaround:
    The library with the necessary files in isn’t included in the SDK for Silverlight but if, in your SL app, you create an empty ReportExceptionAttribute, then applies it to a Report method somewhere in your app like so:


    [AttributeUsage(AttributeTargets.Method)]
    private sealed class ReportExceptionAttribute : Attribute {}


    [ReportException]

    private static void Report(Exception exception)

    {

    throw new Exception("{report}", exception);

    }



    then run it through SA- this is enough for it to trigger the special hooks within SA that generate the right code to perform the reporting.
    The actual bug has reference SA-615.
  • Hi, Chris.

    Will this bring up the Exception Reporting Form(In case I had configured to do)?

    I want to show this form only when an unhandled exception is thrown, but when I catch the exception then I want to send the report in the background.

    Regards,

    Guillermo.
  • Yes, it should bring up the form as usual.
  • Is it possible to show the form only for unhandled exceptions, but send reports in the background whenever I want ?

    Imagine that I have a module which expects a response from a web service. The expected values are "A" or "B". For a particular reason, the web service returns "C", but my module handles this and shows a message to the user: "The service is down, try again later" An smartassembly report is sent in the background so the administrator is notified that the web service is doing wrong. Another module using a different web service also receives a bad response, but does not handle it and an unhandled exception is raised: smartassembly's form shows up to send the report.


    I don't want to build from scratch this kind of "logging" system as I may use smartassembly's reporting feature. Is it possible?
  • Sorry guys but the workaround does not seem to be working. I have logged a formal bug report for this (internal reference SA-615).
  • iosubiosub Posts: 23 Bronze 1
    Wrong Post...
Sign In or Register to comment.