cancel
Showing results for 
Search instead for 
Did you mean: 

Attempted to read or write protected memory

Former Member
0 Kudos

Hi,


I'm using visual studio 2010 with crystal reports (Support Pack 12 (v.13.0.12.1494).

Most of my crystal reports use data from an access database, for an unknown reason I cannot print or export my reports because I'm always presented with the following error "crystal report print Attempted to read or write protected memory. This is often an indication that other memory is corrupt." The application then crashes!

I have a MainForm(startup form) -> projectListForm -> reportForm(crystal report)

In my mainForm's Load event, I'm connecting to the access database that the crystal report also connects too, if I remove this connection in the MainForm then I can actually Export and Print from crystal report when I open the report form;

Also if I set my startup form to the reportForm, the Export and Print work without a problem.

I would greatly appreciate any help I can get!

Thank you,


The exception detail is :

System.AccessViolationException was unhandled

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

  Source=System.Windows.Forms

  StackTrace:

       at System.Windows.Forms.FileDialogNative.IFileDialog.Show(IntPtr parent)

       at System.Windows.Forms.FileDialog.RunDialogVista(IntPtr hWndOwner)

       at System.Windows.Forms.FileDialog.RunDialog(IntPtr hWndOwner)

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

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

       at CrystalDecisions.Windows.Forms.ReportDocumentBase.Export()

       at CrystalDecisions.Windows.Forms.PageView.ExportReport()

       at CrystalDecisions.Windows.Forms.PageView.exportButton_Clicked(Object sender, EventArgs e)

       at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)

       at System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)

       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(IntPtr 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.Application.RunDialog(Form form)

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

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

       at WindowsApplication1.Form1.Button3_Click(Object sender, EventArgs e) in C:\Users\fcapozio\Desktop\Ncl Envirotek\Programming\Test\NCLADMIN\NCLADMIN\Form1.vb:line 345

       at System.Windows.Forms.Control.OnClick(EventArgs e)

       at System.Windows.Forms.Button.OnClick(EventArgs e)

       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

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

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

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

       at System.Windows.Forms.Button.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(IntPtr 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.Application.Run(ApplicationContext context)

       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()

       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()

       at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)

       at WindowsApplication1.My.MyApplication.Main(String[] Args) in 17d14f5c-a337-4978-8281-53493378c1071.vb:line 81

  InnerException:

Accepted Solutions (1)

Accepted Solutions (1)

former_member183750
Active Contributor
0 Kudos

Hi Marc

I am suspecting that when the Access database is being opened, it is creating a lock file (LDB) and this is preventing CR from establishing a connection to the database. See if the following will help:

Introduction to .ldb files in Access 2000</title> <!-- integration code for PDF --> <...


NOTE: If a user opens a database with exclusive access (by clicking the Exclusive check box in the Open dialog box), record locking is not used; therefore, Microsoft Access does not attempt to open or create an .ldb file. If the database is always opened for exclusive use, a user needs only read and write privileges to the folder.

- Ludek

Senior Support Engineer AGS Product Support, Global Support Center Canada

Follow us on Twitter

Former Member
0 Kudos

Hi Ludek,

Thank you for your reply,

It does indeed create an LDB file when it is being opened, but all access databases do, from what I understand the LDB file is important when many users are writing to the database.

After looking further,

I've come to the conclusion that it has to do with the Access format of my database, which is .ACCDB

I've tried converting it to the standard .MDB version and updating it in my datasets, afterwards crystal report was no longer giving me this error when printing or exporting;

I've attached a screenshot of how Crystal Reports is set to connect to my database, when switching over from Provider=Microsoft.ACE.OLEDB.12.0  to Provider=Microsoft.Jet.OLEDB.4.0 it seemed to no longer give me this error.

I rather keep the .ACCDB since I have a few apps connecting to it, hopefully you can look at the screencapture and there may be a different way to connect to it that wouldn't provoke this error?

Thank you

former_member183750
Active Contributor
0 Kudos

Hi Marc

I look to have made a bad assumption - that being that the connection was done via ODBC. CR only supports ODBC connections to accdb. See KBA 1206858 - Crystal Reports cannot connect to the ACCDB file format of a MS Access 2007 using MS DAO c... for details.

- Ludek

Answers (0)