My ramblings in Silverlight, Windows Azure, .NET, ASP.NET, C# (all the way from the UK)
A little place where i can store the snippets of information, which usually get lost in my tiny little brain, and will now forever remain enshrined in the google archives forever.

Monday, 3 March 2008

Silverlight 2 - App.Xaml Events

In Silverlight 2, we have the new App.Xaml file which we can use to store application resources (styles etc), that can be used throughout our Silverlight application.

Application_StartupThis allows you to perform any initialization that you might need to perform in your application on startup.

In order to keep the user experience sweet, I would not recommend any synchronous network calls in this method as it will delay the loading of the application.

Please notice that you must set the RootVisual property to a new instance of your Silverlight Page (plumbeed in for you automatically however).

Application_ExitSince this will be called when your application ends, it might be great to log this back to the server via a web service call. This really would give a great indication on the usage of your application.

I am a little concerned about this call, as it might give those nasty advertising folks a chance to spawn off more instances of the same page (might need to have check on this one, when the beta comes out).

Application_UnhandledException

Since the Application_UnhandledException method will get called if an unhandled exception occurs, this allows you to build a logging mechanism that could report errors directly back to your server.

I would suggest that exposing a standard web service on your server that you could call from this method. Therefore you will be able to log and review any errors in your application (i might knock up such a service soon).