partial void CloseMainWindow()
{
#if NET || SL5
_appClosedFromService = true;
var mainWindow = CatelEnvironment.MainWindow;
if (mainWindow == null)
{
throw Log.ErrorAndCreateException<NotSupportedException>("No main window found (not running SL out of browser? Cannot close application without a window.");
}
if (!_appClosingByMainWindow)
{
#if NET
var app = Application.Current;
app.Shutdown();
#else
mainWindow.Close();
#endif
}
#else
Log.Error("Closing an application is not possible in '{0}'", Platforms.CurrentPlatform);
throw new NotSupportedInPlatformException("Closing an application is not possible");
#endif
}