internal static void ReportUnhandledException(Exception ex, bool willShutDown, bool silently, string tag) { var tags = new List <string> { tag }; if (reporting) { return; } reporting = true; try { var oldReportCrashes = ReportCrashes; if (UnhandledErrorOccured != null && !silently) { ReportCrashes = UnhandledErrorOccured(ReportCrashes, ex, willShutDown); } // If crash reporting has been explicitly disabled, disregard this crash if (ReportCrashes.HasValue && !ReportCrashes.Value) { return; } byte[] data; using (var stream = new MemoryStream()) { using (var writer = System.Xml.XmlWriter.Create(stream)) { writer.WriteStartElement("CrashLog"); writer.WriteAttributeString("version", ServiceVersion); writer.WriteElementString("SystemInformation", SystemInformation.GetTextDescription()); writer.WriteElementString("Exception", ex.ToString()); writer.WriteEndElement(); } data = stream.ToArray(); } if (raygunClient != null) { raygunClient.Send(ex, tags); } // Log to disk only if uploading fails. var filename = string.Format("{0}.{1}.{2}.crashlog", DateTime.UtcNow.ToString("yyyy-MM-dd__HH-mm-ss"), SystemInformation.SessionUuid, Interlocked.Increment(ref CrashId)); ThreadPool.QueueUserWorkItem(delegate { if (!TryUploadReport(filename, data)) { if (!Directory.Exists(CrashLogDirectory)) { Directory.CreateDirectory(CrashLogDirectory); } File.WriteAllBytes(CrashLogDirectory.Combine(filename), data); } }); //ensure we don't lose the setting if (ReportCrashes != oldReportCrashes) { PropertyService.SaveProperties(); } } finally { reporting = false; } }
public static void Initialize(bool updateAddinRegistry) { if (initialized) { return; } Counters.RuntimeInitialization.BeginTiming(); SetupInstrumentation(); Platform.Initialize(); mainThread = mainThread ?? Thread.CurrentThread; // Set a default sync context if (SynchronizationContext.Current == null) { defaultSynchronizationContext = new SynchronizationContext(); SynchronizationContext.SetSynchronizationContext(defaultSynchronizationContext); } else { defaultSynchronizationContext = SynchronizationContext.Current; } // Hook up the SSL certificate validation codepath ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { if (sslPolicyErrors == SslPolicyErrors.None) { return(true); } if (sender is WebRequest) { sender = ((WebRequest)sender).RequestUri.Host; } return(WebCertificateService.GetIsCertificateTrusted(sender as string, certificate.GetPublicKeyString())); }; AddinManager.AddinLoadError += OnLoadError; AddinManager.AddinLoaded += OnLoad; AddinManager.AddinUnloaded += OnUnload; AddinManager.AddinAssembliesLoaded += OnAssembliesLoaded; try { Counters.RuntimeInitialization.Trace("Initializing Addin Manager"); string configDir, addinsDir, databaseDir; GetAddinRegistryLocation(out configDir, out addinsDir, out databaseDir); AddinManager.Initialize(configDir, addinsDir, databaseDir); AddinManager.InitializeDefaultLocalizer(new DefaultAddinLocalizer()); if (updateAddinRegistry) { AddinManager.Registry.Update(null); } setupService = new AddinSetupService(AddinManager.Registry); Counters.RuntimeInitialization.Trace("Initialized Addin Manager"); PropertyService.Initialize(); WebRequestHelper.Initialize(); Mono.Addins.Setup.WebRequestHelper.SetRequestHandler(WebRequestHelper.GetResponse); //have to do this after the addin service and property service have initialized if (UserDataMigrationService.HasSource) { Counters.RuntimeInitialization.Trace("Migrating User Data from MD " + UserDataMigrationService.SourceVersion); UserDataMigrationService.StartMigration(); } RegisterAddinRepositories(); Counters.RuntimeInitialization.Trace("Initializing Assembly Service"); systemAssemblyService = new SystemAssemblyService(); systemAssemblyService.Initialize(); LoadMSBuildLibraries(); initialized = true; } catch (Exception ex) { Console.WriteLine(ex); AddinManager.AddinLoadError -= OnLoadError; AddinManager.AddinLoaded -= OnLoad; AddinManager.AddinUnloaded -= OnUnload; } finally { Counters.RuntimeInitialization.EndTiming(); } }
public static void Initialize(bool updateAddinRegistry) { if (initialized) { return; } Counters.RuntimeInitialization.BeginTiming(); SetupInstrumentation(); Platform.Initialize(); // Set a default sync context if (SynchronizationContext.Current == null) { SynchronizationContext.SetSynchronizationContext(new SynchronizationContext()); } // Hook up the SSL certificate validation codepath System.Net.ServicePointManager.ServerCertificateValidationCallback += delegate(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { if (sslPolicyErrors == SslPolicyErrors.None) { return(true); } if (sender is WebRequest) { sender = ((WebRequest)sender).RequestUri.Host; } return(WebCertificateService.GetIsCertificateTrusted(sender as string, certificate.GetPublicKeyString())); }; AddinManager.AddinLoadError += OnLoadError; AddinManager.AddinLoaded += OnLoad; AddinManager.AddinUnloaded += OnUnload; //provides a development-time way to load addins that are being developed in a asperate solution var devAddinDir = Environment.GetEnvironmentVariable("MONODEVELOP_DEV_ADDINS"); if (devAddinDir != null && devAddinDir.Length == 0) { devAddinDir = null; } try { Counters.RuntimeInitialization.Trace("Initializing Addin Manager"); AddinManager.Initialize( UserProfile.Current.ConfigDir, devAddinDir ?? UserProfile.Current.LocalInstallDir.Combine("Addins"), devAddinDir ?? UserProfile.Current.CacheDir); AddinManager.InitializeDefaultLocalizer(new DefaultAddinLocalizer()); if (updateAddinRegistry) { AddinManager.Registry.Update(null); } setupService = new AddinSetupService(AddinManager.Registry); Counters.RuntimeInitialization.Trace("Initialized Addin Manager"); PropertyService.Initialize(); //have to do this after the addin service and property service have initialized if (UserDataMigrationService.HasSource) { Counters.RuntimeInitialization.Trace("Migrating User Data from MD " + UserDataMigrationService.SourceVersion); UserDataMigrationService.StartMigration(); } RegisterAddinRepositories(); Counters.RuntimeInitialization.Trace("Initializing Assembly Service"); systemAssemblyService = new SystemAssemblyService(); systemAssemblyService.Initialize(); initialized = true; } catch (Exception ex) { Console.WriteLine(ex); AddinManager.AddinLoadError -= OnLoadError; AddinManager.AddinLoaded -= OnLoad; AddinManager.AddinUnloaded -= OnUnload; } finally { Counters.RuntimeInitialization.EndTiming(); } }
static GettextCatalog() { mainThread = Thread.CurrentThread; //variable can be used to override where Gettext looks for the catalogues string catalog = Environment.GetEnvironmentVariable("MONODEVELOP_LOCALE_PATH"); // Set the user defined language string lang = PropertyService.Get("MonoDevelop.Ide.UserInterfaceLanguage", ""); if (!string.IsNullOrEmpty(lang)) { if (Platform.IsWindows) { lang = lang.Replace("_", "-"); CultureInfo ci = CultureInfo.GetCultureInfo(lang); if (ci.IsNeutralCulture) { // We need a non-neutral culture foreach (CultureInfo c in CultureInfo.GetCultures(CultureTypes.AllCultures & ~CultureTypes.NeutralCultures)) { if (c.Parent != null && c.Parent.Name == ci.Name && c.LCID != LOCALE_CUSTOM_UNSPECIFIED) { ci = c; break; } } } if (!ci.IsNeutralCulture) { SetThreadUILanguage(ci.LCID); mainThread.CurrentUICulture = ci; } } else { Environment.SetEnvironmentVariable("LANGUAGE", lang); } } if (string.IsNullOrEmpty(catalog) || !Directory.Exists(catalog)) { string location = System.Reflection.Assembly.GetExecutingAssembly().Location; location = Path.GetDirectoryName(location); if (Platform.IsWindows) { // On windows, load the catalog from a child dir catalog = Path.Combine(location, "locale"); } else { // MD is located at $prefix/lib/monodevelop/bin // adding "../../.." should give us $prefix string prefix = Path.Combine(Path.Combine(Path.Combine(location, ".."), ".."), ".."); if (Platform.IsMac) { prefix = Path.Combine(prefix, "..", "MacOS"); } //normalise it prefix = Path.GetFullPath(prefix); //catalogue is installed to "$prefix/share/locale" by default catalog = Path.Combine(Path.Combine(prefix, "share"), "locale"); } } try { Catalog.Init("monodevelop", catalog); } catch (Exception ex) { Console.WriteLine(ex); } }
public PropertyWrapper(string propertyName, T defaultValue) { this.propertyName = propertyName; value = PropertyService.Get(propertyName, defaultValue); }