static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); AppCenter.Start("03071928-d7cf-4bf5-b512-da1c9bb25975", typeof(Analytics), typeof(Crashes)); AppCenter.LogLevel = LogLevel.Verbose; var config = new NLog.Config.LoggingConfiguration(); // Targets where to log to: File and Console var logfile = new NLog.Targets.FileTarget("logfile") { FileName = "log.foblog" }; // Rules for mapping loggers to targets config.AddRule(NLog.LogLevel.Info, NLog.LogLevel.Fatal, logfile); NLog.LogManager.Configuration = config; if (Crashes.IsEnabledAsync().Result) { StaticData.HasLastCrash = CrashHelper.HasCrashedLastSession(); } StaticData.RunningTime.Start(); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.ThrowException); LoadingFrm = new Loading(); LoadingFrm.Show(); Application.Run(new frmMain(args)); }
public static CrashReport Generate(Exception exception) { StringBuilder builder = new(); DateTime currentTime = DateTime.Now; builder .AppendLine($"PixiEditor {VersionHelpers.GetCurrentAssemblyVersionString()} crashed on {currentTime:yyyy.MM.dd} at {currentTime:HH:mm:ss}\n") .AppendLine("-----System Information----") .AppendLine("General:") .AppendLine($" OS: {Environment.OSVersion.VersionString}") .AppendLine(); CrashHelper helper = new(); try { helper.GetCPUInformation(builder); } catch (Exception cpuE) { builder.AppendLine($"Error ({cpuE.GetType().FullName}: {cpuE.Message}) while gathering CPU information, skipping..."); } try { helper.GetGPUInformation(builder); } catch (Exception gpuE) { builder.AppendLine($"Error ({gpuE.GetType().FullName}: {gpuE.Message}) while gathering GPU information, skipping..."); } try { helper.GetMemoryInformation(builder); } catch (Exception memE) { builder.AppendLine($"Error ({memE.GetType().FullName}: {memE.Message}) while gathering memory information, skipping..."); } CrashHelper.AddExceptionMessage(builder, exception); string filename = $"crash-{currentTime:yyyy-MM-dd_HH-mm-ss_fff}.zip"; string path = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "PixiEditor", "crash_logs"); Directory.CreateDirectory(path); CrashReport report = new(); report.FilePath = Path.Combine(path, filename); report.ReportText = builder.ToString(); return(report); }
private static void Handler_GameExit(object sender, GameExitArg arg) { Console.WriteLine("The game is exit with code:{0}", arg.ExitCode); if (arg.ExitCode != 0) { CrashHelper crashHelper = new CrashHelper(); crashHelper.GetCrashInfo(handler, arg); } }
/// <summary> /// This is the main class for this app. This function is the first function /// called and it setups the app analytic (If in release mode), components, /// requested theme and event handlers. /// </summary> public App() { // Init XAML Resources InitializeComponent(); // We want to use the controler if on xbox if (DeviceHelper.IsXbox) { RequiresPointerMode = ApplicationRequiresPointerMode.WhenRequested; } // Check that we are not using the default theme, // if not change the requested theme to the users // picked theme. if (!SettingsService.Instance.IsDefaultTheme) { RequestedTheme = SettingsService.Instance.ThemeType; } // Registor the dialogs NavigationService.Current.RegisterTypeAsDialog <CrashDialog>(); NavigationService.Current.RegisterTypeAsDialog <FilterDialog>(); NavigationService.Current.RegisterTypeAsDialog <PendingUpdateDialog>(); NavigationService.Current.RegisterTypeAsDialog <PinTileDialog>(); NavigationService.Current.RegisterTypeAsDialog <PlaylistDialog>(); NavigationService.Current.RegisterTypeAsDialog <ShareDialog>(); // Init Keys ApiKeyService.Init(); // Handle App Crashes CrashHelper.HandleAppCrashes(Current); // Enter and Leaving background handlers EnteredBackground += AppEnteredBackground; LeavingBackground += AppLeavingBackground; // During the transition from foreground to background the // memory limit allowed for the application changes. The application // has a short time to respond by bringing its memory usage // under the new limit. MemoryManager.AppMemoryUsageLimitChanging += MemoryManager_AppMemoryUsageLimitChanging; // After an application is backgrounded it is expected to stay // under a memory target to maintain priority to keep running. // Subscribe to the event that informs the app of this change. MemoryManager.AppMemoryUsageIncreased += MemoryManager_AppMemoryUsageIncreased; }
private void TestCrashNative() { CrashHelper.read_null(); CrashHelper.write_null(); }
private static void CurrentDomainOnUnhandledException(object sender, UnhandledExceptionEventArgs unhandledExceptionEventArgs) { CrashHelper.ReportCrash((Exception)unhandledExceptionEventArgs.ExceptionObject); }
private static void ApplicationOnThreadException(object sender, ThreadExceptionEventArgs threadExceptionEventArgs) { CrashHelper.ReportCrash(threadExceptionEventArgs.Exception); }
public App() { // Initialize XAML Resources InitializeComponent(); // Check that we are not using the default theme, // if not change the requested theme to the users // picked theme. if (!SettingsService.Instance.IsDefaultTheme) { RequestedTheme = SettingsService.Instance.ThemeType; } // We want to use the controller if on xbox if (DeviceHelper.IsXbox) { RequiresPointerMode = ApplicationRequiresPointerMode.WhenRequested; } try { // Handle application crashes CrashHelper.HandleAppCrashes(this); } catch { } // Register Event Handlers EnteredBackground += AppEnteredBackground; LeavingBackground += AppLeavingBackground; Suspending += AppSuspending; // Used Reveal Focus on 1803+ if (ApiInformation.IsEnumNamedValuePresent("Windows.UI.Xaml.FocusVisualKind", nameof(FocusVisualKind.Reveal))) { FocusVisualKind = FocusVisualKind.Reveal; } // During the transition from foreground to background the // memory limit allowed for the application changes. The application // has a short time to respond by bringing its memory usage // under the new limit. MemoryManager.AppMemoryUsageLimitChanging += MemoryManager_AppMemoryUsageLimitChanging; // After an application is backgrounded it is expected to stay // under a memory target to maintain priority to keep running. // Subscribe to the event that informs the app of this change. MemoryManager.AppMemoryUsageIncreased += MemoryManager_AppMemoryUsageIncreased; // Run this code when a service is connected to SoundByte SoundByteService.Current.OnServiceConnected += (type, token) => { var vault = new PasswordVault(); // Add the password to the vault so we can access it when restarting the app string vaultName; switch (type) { case ServiceTypes.SoundCloud: case ServiceTypes.SoundCloudV2: vaultName = "SoundByte.SoundCloud"; break; case ServiceTypes.YouTube: vaultName = "SoundByte.YouTube"; break; case ServiceTypes.SoundByte: vaultName = "SoundByte.SoundByteV2"; break; default: vaultName = string.Empty; break; } if (string.IsNullOrEmpty(vaultName)) { return; } vault.Add(new PasswordCredential(vaultName, "Token", token.AccessToken)); vault.Add(new PasswordCredential(vaultName, "RefreshToken", string.IsNullOrEmpty(token.RefreshToken) ? "n/a" : token.RefreshToken)); vault.Add(new PasswordCredential(vaultName, "ExpireTime", string.IsNullOrEmpty(token.ExpireTime) ? "n/a" : token.ExpireTime)); // Track the connect event SimpleIoc.Default.GetInstance <ITelemetryService>().TrackEvent("Service Connected", new Dictionary <string, string> { { "Service", type.ToString() } }); }; // Run this code when a service is disconnected from SoundByte SoundByteService.Current.OnServiceDisconnected += async(type, reason) => { // Delete the vault depending on the service type switch (type) { case ServiceTypes.SoundCloud: case ServiceTypes.SoundCloudV2: SettingsService.Instance.DeleteAllFromVault("SoundByte.SoundCloud"); break; case ServiceTypes.YouTube: SettingsService.Instance.DeleteAllFromVault("SoundByte.YouTube"); break; case ServiceTypes.SoundByte: SettingsService.Instance.DeleteAllFromVault("SoundByte.SoundByteV2"); break; } // Track the disconnect event SimpleIoc.Default.GetInstance <ITelemetryService>().TrackEvent("Service Disconnected", new Dictionary <string, string> { { "Service", type.ToString() }, { "Reason", reason } }); // Attempt to log the user back in if (!string.IsNullOrEmpty(reason)) { // Navigate to the login page NavigateTo(typeof(AccountView), new AccountView.AccountViewParams { Service = type, }); // Tell the user what happened await NavigationService.Current.CallMessageDialogAsync("One of your accounts has been logged out. SoundByte will now redirect you to the login page.", "Account disconnected"); } }; }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException); if (File.Exists("tmp_Updater.exe")) { File.Delete("Updater.exe"); File.Move("tmp_Updater.exe", "Updater.exe"); } Process updater = Process.Start("Updater.exe", "check"); while (!updater.HasExited) { Application.DoEvents(); Thread.Sleep(10); } if (updater.ExitCode == 10) { updater.StartInfo.Arguments = "update"; updater.Start(); return; } AppCenter.Start("03071928-d7cf-4bf5-b512-da1c9bb25975", typeof(Analytics), typeof(Crashes)); AppCenter.LogLevel = LogLevel.Verbose; Console.WriteLine("[INIT] Killing all old chromedriver and chrome instances"); try { foreach (var process in Process.GetProcessesByName("chromedriver")) { try { process.Kill(); } catch (Exception) { } } foreach (var process in Process.GetProcessesByName("chrome")) { try { string commandLine = process.GetCommandLine(); if (commandLine == null) { continue; } if (commandLine.Contains("--no-sandbox") && commandLine.Contains("--enable-automation") && commandLine.Contains("--test-type=webdriver") && commandLine.Contains("--remote-debugging-port=1337")) { process.Kill(); } } catch (Exception) { } } } catch (Exception) { } var config = new NLog.Config.LoggingConfiguration(); var logfile = new NLog.Targets.FileTarget("logfile") { FileName = "log.foblog" }; config.AddRule(NLog.LogLevel.Info, NLog.LogLevel.Fatal, logfile); NLog.LogManager.Configuration = config; if (Crashes.IsEnabledAsync().Result) { StaticData.HasLastCrash = CrashHelper.HasCrashedLastSession(); } StaticData.RunningTime.Start(); LoadingFrm = new Loading(); LoadingFrm.Show(); frmMain main = new frmMain(args); Application.Run(main); }
/// <summary> /// This is the main class for this app. This function is the first function /// called and it setups the app analytic (If in release mode), components, /// requested theme and event handlers. /// </summary> public App() { LoggingService.Log(LoggingService.LogType.Debug, "----- App Started -----"); // Init XAML Resources InitializeComponent(); LoggingService.Log(LoggingService.LogType.Debug, "Loaded XAML"); // We want to use the controler if on xbox if (DeviceHelper.IsXbox) { RequiresPointerMode = ApplicationRequiresPointerMode.WhenRequested; } // Check that we are not using the default theme, // if not change the requested theme to the users // picked theme. if (!SettingsService.Instance.IsDefaultTheme) { RequestedTheme = SettingsService.Instance.ThemeType; } // Register the dialogs NavigationService.Current.RegisterTypeAsDialog <CrashDialog>(); NavigationService.Current.RegisterTypeAsDialog <PendingUpdateDialog>(); NavigationService.Current.RegisterTypeAsDialog <PinTileDialog>(); NavigationService.Current.RegisterTypeAsDialog <PlaylistDialog>(); NavigationService.Current.RegisterTypeAsDialog <ShareDialog>(); NavigationService.Current.RegisterTypeAsDialog <LoginDialog>(); // Live tile helpers TileHelper.Init(); // Init service InitV3Service(); // Handle App Crashes CrashHelper.HandleAppCrashes(Current); // Enter and Leaving background handlers EnteredBackground += AppEnteredBackground; LeavingBackground += AppLeavingBackground; // During the transition from foreground to background the // memory limit allowed for the application changes. The application // has a short time to respond by bringing its memory usage // under the new limit. MemoryManager.AppMemoryUsageLimitChanging += MemoryManager_AppMemoryUsageLimitChanging; // After an application is backgrounded it is expected to stay // under a memory target to maintain priority to keep running. // Subscribe to the event that informs the app of this change. MemoryManager.AppMemoryUsageIncreased += MemoryManager_AppMemoryUsageIncreased; // Run this code when a service is connected to SoundByte SoundByteV3Service.Current.OnServiceConnected += (type, token) => { var vault = new PasswordVault(); // Add the password to the vault so we can access it when restarting the app switch (type) { case ServiceType.SoundCloud: case ServiceType.SoundCloudV2: vault.Add(new PasswordCredential("SoundByte.SoundCloud", "Token", token.AccessToken)); vault.Add(new PasswordCredential("SoundByte.SoundCloud", "Scope", token.Scope)); break; case ServiceType.Fanburst: vault.Add(new PasswordCredential("SoundByte.FanBurst", "Token", token.AccessToken)); break; case ServiceType.YouTube: vault.Add(new PasswordCredential("SoundByte.YouTube", "Token", token.AccessToken)); break; } // Track the connect event TelemetryService.Instance.TrackEvent("Service Connected", new Dictionary <string, string> { { "Service", type.ToString() } }); // Navigate home if we connected SoundCloud, else navigate to explore NavigateTo(type == ServiceType.SoundCloud ? typeof(SoundCloudStreamView) : typeof(ExploreView)); // Update the UI depending if we are logged in or not if (SoundByteV3Service.Current.IsServiceConnected(ServiceType.SoundCloud) || SoundByteV3Service.Current.IsServiceConnected(ServiceType.YouTube) || SoundByteV3Service.Current.IsServiceConnected(ServiceType.Fanburst)) { Shell.ShowLoginContent(); } else { Shell.ShowLogoutContent(); } }; // Run this code when a service is disconencted from SoundByte SoundByteV3Service.Current.OnServiceDisconnected += type => { // Get the password vault var vault = new PasswordVault(); // Delte the vault depending on the service type switch (type) { case ServiceType.SoundCloud: case ServiceType.SoundCloudV2: vault.FindAllByResource("SoundByte.SoundCloud").ForEach(x => vault.Remove(x)); break; case ServiceType.Fanburst: vault.FindAllByResource("SoundByte.FanBurst").ForEach(x => vault.Remove(x)); break; case ServiceType.YouTube: vault.FindAllByResource("SoundByte.YouTube").ForEach(x => vault.Remove(x)); break; } // Track the disconnect event TelemetryService.Instance.TrackEvent("Service Disconnected", new Dictionary <string, string> { { "Service", type.ToString() } }); // Navigate to the explore view NavigateTo(typeof(ExploreView)); // Update the UI depending if we are logged in or not if (SoundByteV3Service.Current.IsServiceConnected(ServiceType.SoundCloud) || SoundByteV3Service.Current.IsServiceConnected(ServiceType.YouTube) || SoundByteV3Service.Current.IsServiceConnected(ServiceType.Fanburst)) { Shell.ShowLoginContent(); } else { Shell.ShowLogoutContent(); } }; }