Telerik.WinControls.UI.ReadingMode.OnDemand; throw exeption

2 posts, 0 answers
  1. Omid
    Omid avatar
    1 posts
    Member since:
    Nov 2013

    Posted 13 Nov 2013 Link to this post


    Hi all 
    i try to view pdf like this 
    01.radPdfViewer1.ReadingMode = Telerik.WinControls.UI.ReadingMode.OnDemand;
    02. 
    03.              using (FileStream fStream = File.OpenRead(dlg.FileName))
    04.              {
    05.                  MemoryStream mStream = new MemoryStream();
    06.                   
    07.                  mStream.SetLength(fStream.Length);
    08.                  fStream.Read(mStream.GetBuffer(), 0, (int)fStream.Length);
    09. 
    10.                  this.radPdfViewer1.LoadDocument(mStream);
    11.              }
    and then the pdf is show.after call radPdfViewer1.PageDown();

    the form throw this exeption

    01.System.Reflection.TargetInvocationException was unhandled
    02.  HResult=-2146232828
    03.  Message=Exception has been thrown by the target of an invocation.
    04.  Source=mscorlib
    05.  StackTrace:
    06.       at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
    07.       at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
    08.       at System.Delegate.DynamicInvokeImpl(Object[] args)
    09.       at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme)
    10.       at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj)
    11.       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    12.       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    13.       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    14.       at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme)
    15.       at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
    16.       at System.Windows.Forms.Control.WndProc(Message& m)
    17.       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
    18.       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
    19.       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
    20.       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
    21.       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
    22.       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
    23.       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
    24.       at System.Windows.Forms.Application.Run(Form mainForm)
    25.       at BookReader.Program.Main() in d:\Omid\Kar\PDF library\Rad\1\BookReader\BookReader\Program.cs:line 18
    26.       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
    27.       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
    28.       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
    29.       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
    30.       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    31.       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
    32.       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
    33.       at System.Threading.ThreadHelper.ThreadStart()
    34.  InnerException: System.Reflection.TargetInvocationException
    35.       HResult=-2146232828
    36.       Message=An exception occurred during the operation, making the result invalid.  Check InnerException for exception details.
    37.       Source=System
    38.       StackTrace:
    39.            at System.ComponentModel.AsyncCompletedEventArgs.RaiseExceptionIfNecessary()
    40.            at System.ComponentModel.RunWorkerCompletedEventArgs.get_Result()
    41.            at Telerik.WinControls.UI.RadFixedPageElement.pageRenderer_RunWorkerCompleted(Object sender, RunWorkerCompletedEventArgs e)
    42.            at System.ComponentModel.BackgroundWorker.OnRunWorkerCompleted(RunWorkerCompletedEventArgs e)
    43.            at System.ComponentModel.BackgroundWorker.AsyncOperationCompleted(Object arg)
    44.       InnerException: System.NullReferenceException
    45.            HResult=-2147467261
    46.            Message=Object reference not set to an instance of an object.
    47.            Source=Telerik.WinControls.PdfViewer
    48.            StackTrace:
    49.                 at Telerik.WinControls.PdfViewer.PdfElementsRenderer.RenderImage(ImageSource source)
    50.                 at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawImage(Image image, Graphics graphics)
    51.                 at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContentElement(IContentElement contentElement, Graphics graphics)
    52.                 at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContainer(Container container, Graphics graphics)
    53.                 at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContentElement(IContentElement contentElement, Graphics graphics)
    54.                 at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContainer(Container container, Graphics graphics)
    55.                 at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawContentElement(IContentElement contentElement, Graphics graphics)
    56.                 at Telerik.WinControls.PdfViewer.FixedPageRenderer.DrawPage(ContentCollection content, Graphics graphics, Matrix pageTransform)
    57.                 at Telerik.WinControls.UI.RadFixedPageElement.pageRenderer_DoWork(Object sender, DoWorkEventArgs e)
    58.                 at System.ComponentModel.BackgroundWorker.OnDoWork(DoWorkEventArgs e)
    59.                 at System.ComponentModel.BackgroundWorker.WorkerThreadStart(Object argument)
    60.            InnerException:

    so when I change readingmode and read large file it accure.

    please help how to handle it.
    thanks every one
  2. Ivan Todorov
    Admin
    Ivan Todorov avatar
    688 posts

    Posted 15 Nov 2013 Link to this post

    Hi Omid,

    Thank you for writing.

    I've tried to reproduce this exception but to no avail. Note that usually the issues in RadPdfViewer depend on the document being opened. Therefore I suggest you try opening different PDF documents and check if the exception is only thrown with some of them. If this is the case, please send us the problematic documents so we can investigate the issue further.

    If the issue is present with all documents you try, then it might be something else which I am missing. Is the code you have posted the only one relevant to RadPdfViewer or you also have other functionality in your project? It would be best if you could send us the full source code of a sample project. This will let us investigate the issue and provide you with a proper answer.

    Looking forward to hearing from you.

    Regards,
    Ivan Todorov
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
    Sign up for Free application insights >>
  3. UI for WinForms is Visual Studio 2017 Ready
Back to Top