Print Error: Access Violation Error

Posted by: slacker-fp on 8 September 2017, 12:58 pm EST

  • Posted 8 September 2017, 12:58 pm EST

    Hi Guys,


    I am having some issues with calling the print Sheet function of spread. I am able to use the function fine when my application on a Windows XP machine but when I load my application on a Vista machine and perform the same steps I get the following Error:


    <FONT color=#ff0000>"Attempted to read or write protected memory. This is often an indication that other memory is corrupt"</FONT>


    <FONT color=#000000>Can anyone suggest what could be causiong this to occur?</FONT>


    Im using the latest version of spread:  v2.5.2013


    The Exception detail follows:


    <FONT face=Calibri color=#ff0000>System.AccessViolationException was unhandled</FONT>


    <FONT face=Calibri color=#ff0000>  Message="Attempted to read or write protected memory. This is often an indication that other memory is corrupt."</FONT>


    <FONT face=Calibri color=#ff0000>  Source="System.Drawing"</FONT>


    <FONT face=Calibri color=#ff0000>  StackTrace:</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Drawing.SafeNativeMethods.PrintDlg(PRINTDLGX86 lppd)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Drawing.Printing.PrinterSettings.GetOutputPort()</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Drawing.Printing.PrinterSettings.FastDeviceCapabilities(Int16 capability, IntPtr pointerToBuffer, Int32 defaultValue, String printerName)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Drawing.Printing.PrinterSettings.Get_PaperSizes()</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Drawing.Printing.PageSettings.PaperSizeFromMode(DEVMODE mode)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Drawing.Printing.PageSettings.GetPaperSize(IntPtr modeHandle)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Drawing.Printing.PageSettings.GetBounds(IntPtr modeHandle)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Drawing.Printing.PageSettings.get_Bounds()</FONT>


    <FONT face=Calibri color=#ff0000>       at FarPoint.Win.Spread.FpSpread.a(SheetView A_0, Boolean A_1, PrintDocument A_2, Boolean& A_3)</FONT>


    <FONT face=Calibri color=#ff0000>       at FarPoint.Win.Spread.FpSpread.a(Int32 A_0, Boolean A_1)</FONT>


    <FONT face=Calibri color=#ff0000>       at FarPoint.Win.Spread.FpSpread.PrintSheet(Int32 sheet)</FONT>


    <FONT face=Calibri color=#ff0000>       at Rubicon.Enterprise.Financials.ReleasePurchaseInvoices.FormPurchaseInvoiceRelease.PrintGrid(FpSpread currentSpread, Boolean showDialog, Boolean showPreview, String header, String footer) in C:\Users\mlawes\Documents\Vb Projects\Enterprise\Financials\Purchase Ledger\Release Purchase Invoices\FormPurchaseInvoiceRelease.vb:line 424</FONT>


    <FONT face=Calibri color=#ff0000>       at Rubicon.Enterprise.Financials.ReleasePurchaseInvoices.FormPurchaseInvoiceRelease.Print(Boolean showdialog, Boolean showpreview) in C:\Users\mlawes\Documents\Vb Projects\Enterprise\Financials\Purchase Ledger\Release Purchase Invoices\FormPurchaseInvoiceRelease.vb:line 395</FONT>


    <FONT face=Calibri color=#ff0000>       at Rubicon.Enterprise.Financials.ReleasePurchaseInvoices.FormPurchaseInvoiceRelease.ToolStripMenuItemPrintPreview_Click(Object sender, EventArgs e) in C:\Users\mlawes\Documents\Vb Projects\Enterprise\Financials\Purchase Ledger\Release Purchase Invoices\FormPurchaseInvoiceRelease.vb:line 332</FONT>


    <FONT face=Calibri color=#ff0000>       at Rubicon.Enterprise.Financials.ReleasePurchaseInvoices.FormPurchaseInvoiceRelease.ReleasePIToolStrip_ItemClicked(Object sender, ToolStripItemClickedEventArgs e) in C:\Users\mlawes\Documents\Vb Projects\Enterprise\Financials\Purchase Ledger\Release Purchase Invoices\FormPurchaseInvoiceRelease.vb:line 249</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.ToolStrip.OnItemClicked(ToolStripItemClickedEventArgs e)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.ToolStrip.HandleItemClick(ToolStripItem dismissingItem)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.Control.WndProc(Message& m)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.ToolStrip.WndProc(Message& m)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Windows.Forms.Form.ShowDialog()</FONT>


    <FONT face=Calibri color=#ff0000>       at Rubicon.Enterprise.Financials.ReleasePurchaseInvoices.Application.RunCommand(String CommandString) in C:\Users\mlawes\Documents\Vb Projects\Enterprise\Financials\Purchase Ledger\Release Purchase Invoices\Application.vb:line 141</FONT>


    <FONT face=Calibri color=#ff0000>       at Rubicon.Enterprise.Financials.ReleasePurchaseInvoices.modGeneral.Main() in C:\Users\mlawes\Documents\Vb Projects\Enterprise\Financials\Purchase Ledger\Release Purchase Invoices\modGeneral.vb:line 47</FONT>


    <FONT face=Calibri color=#ff0000>       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)</FONT>


    <FONT face=Calibri color=#ff0000>       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)</FONT>


    <FONT face=Calibri color=#ff0000>       at System.Threading.ThreadHelper.ThreadStart()</FONT>


    <FONT face=Calibri color=#000000></FONT> 


    <FONT face=Calibri>Please help ...</FONT>


    Regards,


    Slacker :)



     

  • Replied 8 September 2017, 12:58 pm EST

    <SPAN>Hi Guys,<o:p></o:p></SPAN>


    <SPAN>Firstly the code that calls the print function is as follows: </SPAN>


    <BLOCKQUOTE dir=ltr><SPAN>
        <FONT size=2><SPAN class=kwd>Private Sub</SPAN> Print(<SPAN class=kwd>ByVal</SPAN> showdialog <SPAN class=kwd>As Boolean</SPAN>, <SPAN class=kwd>ByVal</SPAN> showpreview <SPAN class=kwd>As Boolean</SPAN>)

    <SPAN class=kwd>Dim</SPAN> header <SPAN class=kwd>As String</SPAN> = <SPAN class=kwd>String</SPAN>.Empty
    <SPAN class=kwd>Dim</SPAN> footer <SPAN class=kwd>As String</SPAN> = <SPAN class=kwd>String</SPAN>.Empty

    header = mPrintSearchCriteria

    footer = <SPAN class=st>"/lPrinted By: "</SPAN> & gDataService.UserName & <SPAN class=st>" ("</SPAN> & Now.ToString(<SPAN class=st>"dd//MMM//yyyy HH:mm"</SPAN>) & <SPAN class=st>")"</SPAN> & <SPAN class=st>"/cPage /p of /pc"</SPAN>
    PrintGrid(FpSpread1, showdialog, showpreview, header, footer)

    </FONT><FONT size=2><SPAN class=kwd>End Sub

    Private Sub</SPAN> PrintGrid(<SPAN class=kwd>ByVal</SPAN> currentSpread <SPAN class=kwd>As</SPAN> FarPoint.Win.Spread.FpSpread, <SPAN class=kwd>ByVal</SPAN> showDialog <SPAN class=kwd>As Boolean</SPAN>, <SPAN class=kwd>ByVal</SPAN> showPreview <SPAN class=kwd>As Boolean</SPAN>, <SPAN class=kwd>ByVal</SPAN> header <SPAN class=kwd>As String</SPAN>, <SPAN class=kwd>ByVal</SPAN> footer <SPAN class=kwd>As String</SPAN>)

    <SPAN class=kwd>Dim</SPAN> printSettings <SPAN class=kwd>As New</SPAN> FarPoint.Win.Spread.PrintInfo
    <SPAN class=kwd>Dim</SPAN> margin <SPAN class=kwd>As New</SPAN> FarPoint.Win.Spread.PrintMargin(30, 30, 30, 30, 30, 0)
    <SPAN class=kwd>Dim</SPAN> whitespace <SPAN class=kwd>As String</SPAN> = <SPAN class=st>" "</SPAN>

    <SPAN class=kwd>With</SPAN> currentSpread

    .SuspendLayout()

    </FONT><FONT size=2><SPAN class=cmt>' Give the document a name
    </SPAN>
    <SPAN class=kwd>With</SPAN> printSettings
    .JobName = PROGRAM_DESCRIPTION & <SPAN class=st>" Printout"</SPAN>
    .Margin = margin
    .Footer = footer
    .Header = header
    .Orientation = FarPoint.Win.Spread.PrintOrientation.Landscape
    </FONT><FONT size=2><SPAN class=cmt>'.BestFitCols = True
    </SPAN>
    .ShowPrintDialog = showDialog
    .Preview = showPreview
    .UseSmartPrint = <SPAN class=kwd>True</SPAN>
    .ShowRowHeaders = </FONT><FONT size=2><SPAN class=kwd>False
    End With</SPAN>

    .ActiveSheet.PrintInfo = printSettings
    .PrintSheet(0)
    .ResumeLayout()

    </FONT><SPAN class=kwd><FONT size=2>End With

    End Sub</FONT></SPAN></PRE></BLOCKQUOTE>
    <P class=MsoNormal dir=ltr></SPAN><SPAN>The error is occurring at the .PrintSheet(0) call.</SPAN>


    <SPAN>The steps prior to the print subroutine call are as follows:<o:p></o:p></SPAN>


    <SPAN>1. Load Application<o:p></o:p></SPAN>


    <SPAN>2. Find the Data and Populate  the Spread sheet.<o:p></o:p></SPAN>


    <SPAN>3. Select Print Preview Button.<o:p></o:p></SPAN>


    <SPAN>Part 3 calls the Print Sub Routine passing in booleans to show preview and dialog.</SPAN>


    <SPAN>The Driver Info is as follows:</SPAN>


    <BLOCKQUOTE dir=ltr>

    <SPAN>HP Buisness Inkjet 1200 series</SPAN>


    <SPAN>Version 2.334.1.0</SPAN>

    </BLOCKQUOTE>

    <SPAN>To be honest I did a little bit more experimentation myself and found if I changed my printer default to out laser print the the error was not reproduced so it could be the HP Inkjet Driver causing the issue.</SPAN>


    <SPAN></SPAN> 


    <SPAN>The Spreadsheet is also attached  to this post.</SPAN>


    <SPAN>If you need anything else please let me know.</SPAN>


    <SPAN>Regards,</SPAN>


    <SPAN>Slacker :)</SPAN>


    2008/01/savespreadstream.zip
  • Replied 8 September 2017, 12:58 pm EST

    Slacker,


    I was not able to test with this XML file because it was referencing a Rubicon.uiReleaseInvoices object that I do not have. Have you tried going to HP website to see if there are any newer printer drivers to see if this fixes the issue? Do you get this error before the Print Dialog control is displayed, before the Print Preview control is displayed, or when you click the Print button from the Print Preview control? Do you have problems printing without the Print Dialog and/or PrintPreview control?

  • Replied 8 September 2017, 12:58 pm EST

    We would need to know more about your print set up so we can attempt to reproduce this here. Could you supply us with the code you are using to invoke the print.
  • Replied 8 September 2017, 12:58 pm EST

    Hello,


    I have not seen this error before. Could you save your spreadsheet to XML file (using the Save method of Spread) and zip that up with the code you are using for printing and the name of the printer driver you are printing to? Then we can debug this issue to see what is happening.

  • Replied 8 September 2017, 12:58 pm EST

    Hello,


    When you reply to the post, there is an Options tab above the text. You can click on that to go to the section to add an attachment. The attachment must be zipped and less than 256KB.

  • Replied 8 September 2017, 12:58 pm EST

    Another good test is to comment all the PrintInfo settings and just call PrintSheet. If the bug is not reproducible with just that call, add back each item one at a time and test which property setting causes the error.
  • Replied 8 September 2017, 12:58 pm EST

    Two of my users are reporting this same error.  version 4.0.2026.2005 of FarPoint Spread control.


    "FpSpread Attempted to read or write protected memory.  This is often an indication that other memory is corrupt."


    Everyone on my team is able to print to a Canon IR5055 without issue or error.  Everyone on the team down in DC is unable to print to their HP LaserJet P2050 Series PCL6 and are getting the error above.  I was able to successfully print to the HP LaserJet P2050 Series PCL6.  This leaves me scratching my head in confusion.  We all have the same setups in theory (XP and Farpoint Spread control 4.0.2026.2005).  Here is the code executing the print.  Any suggestions?  Thanks!<FONT size=2>


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Private</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub</FONT></FONT><FONT size=2> mnuPrint_Click(</FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT size=2> sender </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Object</FONT></FONT><FONT size=2>, _


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>ByVal</FONT></FONT><FONT size=2> e </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> System.EventArgs) </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Handles</FONT></FONT><FONT size=2> mnuPrint.Click


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Try

    </FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>If</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Me</FONT></FONT><FONT size=2>.PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Then

    </FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Dim</FONT></FONT><FONT size=2> printset </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>New</FONT></FONT><FONT size=2> FarPoint.Win.Spread.PrintInfo


    printset.Printer = </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Me</FONT></FONT><FONT size=2>.PrintDialog1.PrinterSettings.PrinterName


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Me</FONT></FONT><FONT size=2>.FpSpread1.Sheets(0).PrintInfo = printset


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Me</FONT></FONT><FONT size=2>.FpSpread1.PrintSheet(0)


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>If

    </FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Catch</FONT></FONT><FONT size=2> ex </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>As</FONT></FONT><FONT size=2> Exception


    MsgBox(ex.Message)


    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Try

    </FONT></FONT><FONT size=2>

    </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>End</FONT></FONT><FONT size=2> </FONT><FONT color=#0000ff size=2><FONT color=#0000ff size=2>Sub

    </FONT></FONT>
  • Replied 8 September 2017, 12:58 pm EST

    Hello,


    Since it works in your setting, I would check what may be different between the two computers, specifically the version of the print driver being used.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels