Search code examples
visual-studio-2015template10

Template10 SettingsService exception


Using Template10 1.18, and when suspending App in VisualStudio (using lifecycle events), I am seeing "the size of the state manager setting value has exceeded the limit". As seen in the stack trace below, Template10.Services.SettingsService.SettingsService.Write is directly involved. I know one answer is to not use the Setting service, and do file writes for data when suspending, but Template10 is handling this so it seems best to let it. If I must turn off Template10 Setting service, how? Or can I override the method and avoid using LocalSettings?

NMA-Client.McgInterop.dll!System.Runtime.InteropServices.WindowsRuntime.IMapSharedReferenceTypesStubClass.Insert(System.Collections.Generic.IDictionary _this, string key, object value) Line 2176 C# NMA-Client.McgInterop.dll!Windows.Storage.ApplicationDataCompositeValue.System.Collections.Generic.IDictionary.set_Item(string index, object value) Line 9704 C# Template10Library.dll!Template10.Services.SettingsService.SettingsService.Write(string key, string value) Unknown Template10Library.dll!Template10.Services.NavigationService.NavigationService.SaveNavigationAsync() Unknown Template10Library.dll!Template10.Services.NavigationService.NavigationService.SaveNavigationAsync() Unknown Template10Library.dll!Template10.Services.NavigationService.NavigationService.SuspendingAsync() Unknown Template10Library.dll!Template10.Services.NavigationService.NavigationService.SuspendingAsync() Unknown Template10Library.dll!Template10.Common.BootStrapper.HandleSuspending() Unknown Template10Library.dll!Template10.Common.BootStrapper.HandleSuspending.AnonymousMethod__2() Unknown Template10Library.dll!Template10.Common.DispatcherWrapper.DispatchAsync() Unknown Template10Library.dll!Template10.Common.DispatcherWrapper.DispatchAsync(System.Func func, int delayms, Windows.UI.Core.CoreDispatcherPriority priority) Unknown Template10Library.dll!Template10.Common.BootStrapper.HandleSuspending() Unknown Template10Library.dll!Template10.Common.BootStrapper.HandleSuspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e) Unknown System.Private.SharedLibrary.Interop.Generated.dll!Windows.Foundation.AsyncOperationProgressHandler.Invoke(Windows.Foundation.IAsyncOperationWithProgress asyncInfo, uint progressInfo) C# NMA-Client.McgInterop.dll!McgInterop.ReverseComSharedStubs.Proc_object__TArg0__(object __this, System.Runtime.InteropServices.__vtable_IInspectable* unsafe_sender, void* unsafe_e, System.IntPtr __methodPtr) Line 9745 C# NMA-Client.McgInterop.dll!Windows.UI.Xaml.SuspendingEventHandler__Impl.Vtbl.Invoke__STUB(System.IntPtr pComThis, System.Runtime.InteropServices.__vtable_IInspectable* unsafe_sender, Windows.ApplicationModel.ISuspendingEventArgs__Impl.Vtbl** unsafe_e) Line 94537 C#


Solution

  • The Template 10 SettingService is a generic wrapper for SettingHelper intended for 90% of developers. It appears your app needs a special implementation. You can copy the existing SettingsService into your project to solve your problem. I realize SettingService won't work for 10% of the apps out there. You are one of the lucky 10%. But your custom wrapper should solve this.

    Get the source here https://github.com/Windows-XAML/Template10/blob/master/Template10%20(Library)/Services/SettingsService/SettingsService.cs