Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
35
LoadCustomizations unhandled exception with invalid xml format
posted

I am using 17.2 and have following code,

try
                        {
                            string error = null;
                            this.DataGridControl.LoadCustomizations(fs, true, out error, CustomizationType.None);
                        }
            catch(Exception ex)
                        {
                            //ignore exception caused by loading xml file, like invalid element etc
                        }

I have manually changed xml element (<fieldLayouts> to <fieldLayouts1>) in saved xml file created by SaveCustomizations(fs, true) and then loaded with above code. As expected I can see error message as below, and no exception catch from above.

The 'fieldLayouts1' start tag on line 3 position 4 does not match the end tag of 'fieldLayouts'. Line 71, position 5.

Issue is after exit from above code and keep running there is an unhandled exception as below, and I have no way to catch it.

System.Reflection.TargetInvocationException
  HResult=0x80131604
  Message=Exception has been thrown by the target of an invocation.
  Source=mscorlib
  StackTrace:
   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 MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext 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)

Inner Exception 1:
InvalidOperationException: Invalid root element in LoadCustomizations.

Can anyone tell me although I have returned error message from LoadCustomizations why exception isn't handled internally by XamDataGrid control? Thanks!

Parents
No Data
Reply
  • 34810
    Offline posted

    Hello Jiyang,

    I have been investigating into the behavior you are seeing, and I believe I am able to see the exception that you are receiving, but this exception appears to be a first-chance exception, and will not happen if you do not have a checkmark placed to break on it in your Common Language Runtime Exceptions option of the Debug => Exception Settings in Visual Studio. This exception can be continued through, and you will not see it if running without the debugger.

    Just to ensure that we are indeed seeing the same behavior, I am attaching the sample project I used to test this. It will be helpful if you can run this sample on your end and verify that it is the same behavior. I created this sample project against version 17.2.20172.2143 of Infragistics for WPF 2017.2. Is this the same version you are using?

    Please let me know if you have any other questions or concerns on this matter.

    XDGSaveLoadExceptionCase.zip

Children