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:

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

    Can anyone suggest what could be causiong this to occur?

    Im using the latest version of spread:  v2.5.2013

    The Exception detail follows:

    System.AccessViolationException was unhandled

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



           at System.Drawing.SafeNativeMethods.PrintDlg(PRINTDLGX86 lppd)

           at System.Drawing.Printing.PrinterSettings.GetOutputPort()

           at System.Drawing.Printing.PrinterSettings.FastDeviceCapabilities(Int16 capability, IntPtr pointerToBuffer, Int32 defaultValue, String printerName)

           at System.Drawing.Printing.PrinterSettings.Get_PaperSizes()

           at System.Drawing.Printing.PageSettings.PaperSizeFromMode(DEVMODE mode)

           at System.Drawing.Printing.PageSettings.GetPaperSize(IntPtr modeHandle)

           at System.Drawing.Printing.PageSettings.GetBounds(IntPtr modeHandle)

           at System.Drawing.Printing.PageSettings.get_Bounds()

           at FarPoint.Win.Spread.FpSpread.a(SheetView A_0, Boolean A_1, PrintDocument A_2, Boolean& A_3)

           at FarPoint.Win.Spread.FpSpread.a(Int32 A_0, Boolean A_1)

           at FarPoint.Win.Spread.FpSpread.PrintSheet(Int32 sheet)

           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

           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

           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

           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

           at System.Windows.Forms.ToolStrip.OnItemClicked(ToolStripItemClickedEventArgs e)

           at System.Windows.Forms.ToolStrip.HandleItemClick(ToolStripItem dismissingItem)

           at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)

           at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)

           at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)

           at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)

           at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)

           at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

           at System.Windows.Forms.Control.WndProc(Message& m)

           at System.Windows.Forms.ScrollableControl.WndProc(Message& m)

           at System.Windows.Forms.ToolStrip.WndProc(Message& m)

           at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

           at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

           at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

           at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

           at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

           at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

           at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

           at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)

           at System.Windows.Forms.Form.ShowDialog()

           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

           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

           at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)

           at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

           at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

           at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

           at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

           at System.Threading.ThreadHelper.ThreadStart()


    Please help ...


    Slacker :)


  • 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


    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


    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

    Hi Guys,

    Firstly the code that calls the print function is as follows:

        Private Sub Print(ByVal showdialog As Boolean, ByVal showpreview As Boolean)

    Dim header As String = String.Empty
    Dim footer As String = String.Empty

    header = mPrintSearchCriteria

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

    End Sub

    Private Sub
    PrintGrid(ByVal currentSpread As FarPoint.Win.Spread.FpSpread, ByVal showDialog As Boolean, ByVal showPreview As Boolean, ByVal header As String, ByVal footer As String)

    Dim printSettings As New FarPoint.Win.Spread.PrintInfo
    Dim margin As New FarPoint.Win.Spread.PrintMargin(30, 30, 30, 30, 30, 0)
    Dim whitespace As String = " "

    With currentSpread


    ' Give the document a name

    With printSettings
    .JobName = PROGRAM_DESCRIPTION & " Printout"
    .Margin = margin
    .Footer = footer
    .Header = header
    .Orientation = FarPoint.Win.Spread.PrintOrientation.Landscape
    '.BestFitCols = True

    .ShowPrintDialog = showDialog
    .Preview = showPreview
    .UseSmartPrint = True
    .ShowRowHeaders =
    End With

    .ActiveSheet.PrintInfo = printSettings

    End With

    End Sub

    The error is occurring at the .PrintSheet(0) call.

    The steps prior to the print subroutine call are as follows:

    1. Load Application

    2. Find the Data and Populate  the Spread sheet.

    3. Select Print Preview Button.

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

    The Driver Info is as follows:

    HP Buisness Inkjet 1200 series

    Version 2.334.1.0

    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.


    The Spreadsheet is also attached  to this post.

    If you need anything else please let me know.


    Slacker :)

  • Replied 8 September 2017, 12:58 pm EST


    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

    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!

    Private Sub mnuPrint_Click(ByVal sender As Object, _

    ByVal e As System.EventArgs) Handles mnuPrint.Click


    If Me.PrintDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then

    Dim printset As New FarPoint.Win.Spread.PrintInfo

    printset.Printer = Me.PrintDialog1.PrinterSettings.PrinterName

    Me.FpSpread1.Sheets(0).PrintInfo = printset


    End If

    Catch ex As Exception


    End Try

    End Sub

  • Replied 8 September 2017, 12:58 pm EST


    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