1

I am developing a WPF application build on .NET framework 4.5 and .NET 4.6 is installed on system. I am using UserPreference class to store my some of the variables and I save them when i exit the application. While exiting from application, some times I observe exception as mentioned below.

[09/14/15 12:01:49]  Critical : APPLICATION     : Application Error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: The parameter 'sectionGroupName' is invalid.
Parameter name: sectionGroupName
   at System.Configuration.MgmtConfigurationRecord.GetSectionGroup(String configKey)
   at System.Configuration.ClientSettingsStore.DeclareSection(Configuration config, String sectionName)
   at System.Configuration.ClientSettingsStore.GetConfigSection(Configuration config, String sectionName, Boolean declare)
   at System.Configuration.ClientSettingsStore.WriteSettings(String sectionName, Boolean isRoaming, IDictionary newSettings)
   at System.Configuration.LocalFileSettingsProvider.SetPropertyValues(SettingsContext context, SettingsPropertyValueCollection values)
   at System.Configuration.SettingsBase.SaveCore()
   at System.Configuration.SettingsBase.Save()
   at System.Configuration.ApplicationSettingsBase.Save()
   at MyWpfApplication2.Database.UserPreferenceManager.Save()
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Windows.Threading.DispatcherOperation.InvokeInSecurityContext(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at System.Windows.Application.Run(Window window)
   at System.Windows.Application.Run()
   at MyWpfApplication2.AppController.App.Main()

I did some googling regarding this error, but none of them said about wpf application. They all were saying about web and others, so did not find some satisfying answer.

pratik03
  • 651
  • 2
  • 7
  • 23
  • 1
    can you show us the code that throws this error? – simonalexander2005 Sep 16 '15 at 10:25
  • Actually I don't know the exact code which throws exception, but I catch this exception in UnhandledException() method defined in app.xaml.cs. – pratik03 Sep 16 '15 at 10:30
  • Have you looked at the inner exception details? – simonalexander2005 Sep 16 '15 at 11:00
  • I am getting this exception when application is run through exe, not from visual studio. So i have nothing except this debug. And one more problem is, I don't get this error every time. one more thing, a timer is running on main thread which saves User setting once it is changed after 3 mins. – pratik03 Sep 16 '15 at 11:44
  • OK. Can you show the code that calls save then? Any code that interacts with the user preferences. Also, are you coding in C#, vb.net or something else? – simonalexander2005 Sep 16 '15 at 12:19

0 Answers0