This is a migrated thread and some comments may be shown as answers.

Is there any way to catch errors in ReportViewModel.OnPrintingComplete?

2 Answers 105 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
jholt
Top achievements
Rank 1
jholt asked on 03 Mar 2011, 08:41 PM
Hi

I am trying to catch an exception that is being thrown in the Telerik.ReportViewer.Wpf.ReportViewerModel. 

System.Reflection.TargetInvocationException
Exception has been thrown by the target of an invocation.
   at System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
   at System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
   at System.Delegate.DynamicInvokeImpl(Object[] args)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
Inner Exception:System.Printing.PrintSystemException
Printing was canceled. Win32 error: The specified printer has been deleted.


   at Microsoft.Internal.GDIExporter.CGDIRenderTarget.StartDocument(String printerName, String jobName, String filename, Byte[] devmode)
   at Microsoft.Internal.AlphaFlattener.MetroToGdiConverter.StartDocument(String jobName, PrintTicket ticket)
   at System.Windows.Xps.Serialization.NgcSerializationManager.StartDocument(Object o, Boolean documentPrintTicketRequired)
   at System.Windows.Xps.Serialization.NgcDocumentPaginatorSerializer.SerializeObject(Object serializedObject)
   at System.Windows.Xps.Serialization.NgcSerializationManager.SaveAsXaml(Object serializedObject)
   at System.Windows.Xps.XpsDocumentWriter.SaveAsXaml(Object serializedObject, Boolean isSync)
   at System.Windows.Xps.XpsDocumentWriter.Write(DocumentPaginator documentPaginator)
   at System.Windows.Controls.PrintDialog.PrintDocument(DocumentPaginator documentPaginator, String description)
   at Telerik.ReportViewer.Wpf.ReportViewerModel.OnPrintingComplete(RenderingThreadResult result, EventArgs args)

While I could handle the error at the application  level, I would like to handle the error closer to the source. The ReportViewModel does not expose any interesting methods to override, and the ReportViewer.Error event does not pick up what is basically a system level error ("The specified printer has been deleted").

Where should I catch this kind of error?

Many thanks
Jeremy

2 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 09 Mar 2011, 10:43 AM
Hi Jeremy,

The exception thrown in your case is probably due to a misconfiguration of your printers and would be raised in any program that is trying to use it being a system error. The correct/ideal solution is to ensure that there are no exceptions raised as a whole in your app and this has to be done at application level.


All the best,
Steve
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
jholt
Top achievements
Rank 1
answered on 10 Mar 2011, 08:13 AM
Hi Steve

Thanks your reply.

I just ended up catching the error in App.cs.

Thanks anyway

Regards
Jeremy
Tags
General Discussions
Asked by
jholt
Top achievements
Rank 1
Answers by
Steve
Telerik team
jholt
Top achievements
Rank 1
Share this question
or