Hi,
I have a problem with the DocumentViewer control (.NET 4.0). In our application we want to display xps-documents (created by our customers) with the Documentviewer control. They often contain huge images, but we have no direct influence on the creation of the xps-documents (partially scanned, etc.). Navigating these xps documents sometimes results in a crash of the application with the following Exception (OutOfMemoryException):
Application_DispatcherUnhandledException:
EXCEPTION: System.OutOfMemoryException
SOURCE: PresentationCore
MESSAGE: Nicht genügend Speicher verfügbar, um das Programm weiter auszuführen.
STACKTRACE:
bei System.Windows.Media.Composition.DUCE.Channel.SyncFlush()
bei System.Windows.Interop.HwndTarget.UpdateWindowSettings(Boolean enableRenderTarget, Nullable`1 channelSet)
bei System.Windows.Interop.HwndTarget.UpdateWindowPos(IntPtr lParam)
bei System.Windows.Interop.HwndTarget.HandleMessage(WindowMessage msg, IntPtr wparam, IntPtr lparam)
bei System.Windows.Interop.HwndSource.HwndTargetFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
bei MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
bei MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
bei System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
bei MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)
Navigation in the DocumentViewer is done with the GoToPage Method. The DocumentViewer takes a while until the page is displayed with its content (display-delay). Sometimes when I for example maximized and again normalized the window during this display-delay,
the application crashes with the given exception. My application is build with x86 because of some native libraries. With a sample application it doesn't crash when I build it with "any CPU" on my development machine.Building it with x86 it crashes
sometimes.
So could someone give some hints about what can I do here. I would be very glad, if there is a way to catch this exception without crashing the whole application.
As said, I know that we have huge images in there, but if they are too huge for the application memory or the graphics card memory to handle, than I would be great if there is a way for me to check this before the application crashes. On the other hand, I know that it works if i just do nothing with the application but waiting for DocumentViewer to complete its work, but I can't forbid the user to interact with the application because there is some loading in the background.
Any suggestions are welcome.