Example #1
0
        private void OnAppStartup(object sender, StartupEventArgs e)
        {
            Exit          += (_, __) => IsShuttingDown = true;
            HasIdentity    = PackageHelper.CheckHasIdentity();
            PackageVersion = PackageHelper.GetVersion(HasIdentity);
            _settings      = new AppSettings();
            _errorReporter = new ErrorReporter();

            if (SingleInstanceAppMutex.TakeExclusivity())
            {
                Exit += (_, __) => SingleInstanceAppMutex.ReleaseExclusivity();

                try
                {
                    ContinueStartup();
                }
                catch (Exception ex) when(IsCriticalFontLoadFailure(ex))
                {
                    ErrorReporter.LogWarning(ex);
                    OnCriticalFontLoadFailure();
                }
            }
            else
            {
                Shutdown();
            }
        }
Example #2
0
        public static bool HasIdentity(this Application app)
        {
#if VSDEBUG
            if (Debugger.IsAttached)
            {
                return false;
            }
#endif

            if (_hasIdentity == null)
            {
                try
                {
                    _hasIdentity = (Package.Current.Id != null);
                }
                catch (InvalidOperationException ex)
                {
                    _hasIdentity = false;
#if !DEBUG
                    // We do not expect this to occur in production when the app is packaged.
                    ErrorReporter.LogWarning(ex);
#else
                    Trace.WriteLine($"AppExtensions HasIdentity: False {ex.Message}");
#endif
                }
            }

            return (bool)_hasIdentity;
        }
Example #3
0
        private void OnAppStartup(object sender, StartupEventArgs e)
        {
            Exit          += (_, __) => IsShuttingDown = true;
            _errorReporter = new ErrorReporter();

            if (SingleInstanceAppMutex.TakeExclusivity())
            {
                Exit += (_, __) => SingleInstanceAppMutex.ReleaseExclusivity();

                try
                {
                    ContinueStartup();
                }
                catch (Exception ex) when(ex.StackTrace.Contains(
                                              "MS.Internal.Text.TextInterface.FontFamily.GetFirstMatchingFont"))
                {
                    ErrorReporter.LogWarning(ex);
                    OnCriticalFontLoadFailure();
                }
            }
            else
            {
                Shutdown();
            }
        }
Example #4
0
 static void WriteSetting <T>(string key, T value)
 {
     try
     {
         Windows.Storage.ApplicationData.Current.LocalSettings.Values[key] = value;
     }
     catch (Exception ex)
     {
         // Windows Bug: Windows Storage APIs are still unreliable
         ErrorReporter.LogWarning(ex);
     }
 }
Example #5
0
        public bool HasKey(string key)
        {
            var ret = false;

            try
            {
                ret = Windows.Storage.ApplicationData.Current.LocalSettings.Values.ContainsKey(key);
            }
            catch (Exception ex)
            {
                ErrorReporter.LogWarning(ex);
            }
            return(ret);
        }
Example #6
0
        static T ReadSetting <T>(string key, T defaultValue)
        {
            T ret = defaultValue;

            try
            {
                ret = (T)Windows.Storage.ApplicationData.Current.LocalSettings.Values[key];
            }
            catch (Exception ex)
            {
                // Windows Bug: Windows Storage APIs are still unreliable
                ErrorReporter.LogWarning(ex);
            }
            return(ret);
        }