cancel
Showing results for 
Search instead for 
Did you mean: 

Unhandled Exception Attempted to read or write protected memory VB2008

Former Member
0 Kudos

Hello all,

I have been reading and searching for an answer to this and I'm unable to locate anything. I have written a program in which a farmer creates a ticket and prints a bill of lading. On the print button I execute the following code:

Try
            successSaveTicket = saveTicketDetails()
            If successSaveTicket = True Then
                If Me.lstDetails.Items.Count > 0 Then
                    Dim newticket As New rptTicket
                    Dim reportViewer As New frmReportViewer

                    '================================
                    newticket.Load()
                    '
                    ' Declare the parameter related objects.
                    '
                    Dim crParameterDiscreteValue As ParameterDiscreteValue
                    Dim crParameterFieldDefinitions As ParameterFieldDefinitions
                    Dim crParameterFieldLocation As ParameterFieldDefinition
                    Dim crParameterValues As ParameterValues
                    '
                    ' Get the report's parameters collection.
                    '
                    crParameterFieldDefinitions = newticket.DataDefinition.ParameterFields
                    '
                    ' Set the first parameter
                    ' - Get the parameter, tell it to use the current values vs default value.
                    ' - Tell it the parameter contains 1 discrete value vs multiple values.
                    ' - Set the parameter's value.
                    ' - Add it and apply it.
                    ' - Repeat these statements for each parameter.
                    '
                    crParameterFieldLocation = crParameterFieldDefinitions.Item("ticketNumber")
                    crParameterValues = crParameterFieldLocation.CurrentValues
                    crParameterDiscreteValue = New CrystalDecisions.Shared.ParameterDiscreteValue
                    crParameterDiscreteValue.Value = Long.Parse(Me.txtTicketNumber.Text)
                    crParameterValues.Add(crParameterDiscreteValue)
                    crParameterFieldLocation.ApplyCurrentValues(crParameterValues)

                    newticket.PrintToPrinter(1, False, 0, 0)

                    fillOpenTickets()
                    clearLoadDetails()
                    Me.grpLoadDetails.Enabled = True
                    Me.grpCreateTicket.Enabled = False
                    Me.grpTickets.Enabled = True
                    ErrorProvider1.Clear()
                    Me.btnNewTicket.Focus()

                    'Show report in viewer to print? is causing memory error though
                    reportViewer.viewer.ReportSource = newticket
                    reportViewer.Show()

                Else
                    MsgBox("There are no related details for this ticket to print")
                    Me.cmbProduct.Focus()
                End If
            End If
        Catch ex As Exception
            MsgBox("Error in printing: " & ex.Message.ToString)
        End Try

Edited by: Don Williams on Feb 27, 2011 7:06 AM

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

In my test enviroment everything works perfectly, the report prints to the printer without issue. I built the setup, installed the crystal runtimes, and installed the program. When I go to print the ticket it still prints perfectly fine but after the print has been sent I get this error:

"Unhandled exception has occured in your accplication. If you click continue, the application will ignore this error and attempt to continue. BLA BLA BLA Attempted to read or write to protected memory. This is often an indication that other memory is corrupt."

Then if you click details I get the following:

See the end of this message for details on invoking

just-in-time (JIT) debugging instead of this dialog box.

                            • Exception Text **************

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

at System.Windows.Forms.UnsafeNativeMethods.CallWindowProc(IntPtr wndProc, IntPtr hWnd, Int32 msg, IntPtr wParam, IntPtr lParam)

at System.Windows.Forms.NativeWindow.DefWndProc(Message& m)

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

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

at System.Windows.Forms.ComboBox.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.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

                            • Loaded Assemblies **************

mscorlib

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.4952 (win7RTMGDR.050727-4900)

CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v2.0.50727/mscorlib.dll

-


JMRFarmsRemote

Assembly Version: 1.0.0.0

Win32 Version: 1.0.0.0

CodeBase: file:///C:/Users/cmengerink1/AppData/Roaming/Microsoft/Windows/Start%20Menu/Programs/JMR%20Farms%20Remote/JMRFarmsRemote.exe

-


Microsoft.VisualBasic

Assembly Version: 8.0.0.0

Win32 Version: 8.0.50727.4927 (NetFXspW7.050727-4900)

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/Microsoft.VisualBasic/8.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualBasic.dll

-


System

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System/2.0.0.0__b77a5c561934e089/System.dll

-


System.Windows.Forms

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Windows.Forms/2.0.0.0__b77a5c561934e089/System.Windows.Forms.dll

-


System.Drawing

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Drawing/2.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll

-


System.Runtime.Remoting

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Runtime.Remoting/2.0.0.0__b77a5c561934e089/System.Runtime.Remoting.dll

-


System.Configuration

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Configuration/2.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll

-


0 Kudos

System.Xml

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Xml/2.0.0.0__b77a5c561934e089/System.Xml.dll

-


System.Data

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)

CodeBase: file:///C:/Windows/assembly/GAC_32/System.Data/2.0.0.0__b77a5c561934e089/System.Data.dll

-


System.Transactions

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)

CodeBase: file:///C:/Windows/assembly/GAC_32/System.Transactions/2.0.0.0__b77a5c561934e089/System.Transactions.dll

-


System.EnterpriseServices

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)

CodeBase: file:///C:/Windows/assembly/GAC_32/System.EnterpriseServices/2.0.0.0__b03f5f7f11d50a3a/System.EnterpriseServices.dll

-


CrystalDecisions.Shared

Assembly Version: 10.5.3700.0

Win32 Version: 10.5.0.1943

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/CrystalDecisions.Shared/10.5.3700.0__692fbea5521e1304/CrystalDecisions.Shared.dll

-


CrystalDecisions.CrystalReports.Engine

Assembly Version: 10.5.3700.0

Win32 Version: 10.5.0.1943

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/CrystalDecisions.CrystalReports.Engine/10.5.3700.0__692fbea5521e1304/CrystalDecisions.CrystalReports.Engine.dll

-


CrystalDecisions.Windows.Forms

Assembly Version: 10.5.3700.0

Win32 Version: 10.5.0.1943

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/CrystalDecisions.Windows.Forms/10.5.3700.0__692fbea5521e1304/CrystalDecisions.Windows.Forms.dll

-


CrystalDecisions.ReportAppServer.CommLayer

Assembly Version: 10.5.3700.0

Win32 Version: 10.5.0.1943

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/CrystalDecisions.ReportAppServer.CommLayer/10.5.3700.0__692fbea5521e1304/CrystalDecisions.ReportAppServer.CommLayer.dll

-


CrystalDecisions.ReportAppServer.ClientDoc

Assembly Version: 10.5.3700.0

Win32 Version: 10.5.0.1943

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/CrystalDecisions.ReportAppServer.ClientDoc/10.5.3700.0__692fbea5521e1304/CrystalDecisions.ReportAppServer.ClientDoc.dll

-


CrystalDecisions.ReportAppServer.DataSetConversion

Assembly Version: 10.5.3700.0

Win32 Version: 10.5.0.1943

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/CrystalDecisions.ReportAppServer.DataSetConversion/10.5.3700.0__692fbea5521e1304/CrystalDecisions.ReportAppServer.DataSetConversion.dll

-


CrystalDecisions.ReportAppServer.DataDefModel

Assembly Version: 10.5.3700.0

Win32 Version: 10.5.0.1943

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/CrystalDecisions.ReportAppServer.DataDefModel/10.5.3700.0__692fbea5521e1304/CrystalDecisions.ReportAppServer.DataDefModel.dll

-


0 Kudos

CrystalDecisions.ReportAppServer.Controllers

Assembly Version: 10.5.3700.0

Win32 Version: 10.5.0.1943

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/CrystalDecisions.ReportAppServer.Controllers/10.5.3700.0__692fbea5521e1304/CrystalDecisions.ReportAppServer.Controllers.dll

-


CrystalDecisions.ReportAppServer.ReportDefModel

Assembly Version: 10.5.3700.0

Win32 Version: 10.5.0.1943

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/CrystalDecisions.ReportAppServer.ReportDefModel/10.5.3700.0__692fbea5521e1304/CrystalDecisions.ReportAppServer.ReportDefModel.dll

-


CrystalDecisions.KeyCode

Assembly Version: 10.5.3700.0

Win32 Version: 10.5.0.1943

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/CrystalDecisions.KeyCode/10.5.3700.0__692fbea5521e1304/CrystalDecisions.KeyCode.dll

-


System.Web

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.4955 (win7RTMGDR.050727-4900)

CodeBase: file:///C:/Windows/assembly/GAC_32/System.Web/2.0.0.0__b03f5f7f11d50a3a/System.Web.dll

-


CrystalDecisions.ReportSource

Assembly Version: 10.5.3700.0

Win32 Version: 10.5.0.1943

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/CrystalDecisions.ReportSource/10.5.3700.0__692fbea5521e1304/CrystalDecisions.ReportSource.dll

-


CustomMarshalers

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)

CodeBase: file:///C:/Windows/assembly/GAC_32/CustomMarshalers/2.0.0.0__b03f5f7f11d50a3a/CustomMarshalers.dll

-


System.Web.Services

Assembly Version: 2.0.0.0

Win32 Version: 2.0.50727.4927 (NetFXspW7.050727-4900)

CodeBase: file:///C:/Windows/assembly/GAC_MSIL/System.Web.Services/2.0.0.0__b03f5f7f11d50a3a/System.Web.Services.dll

-


CrystalDecisions.Enterprise.Framework

Assembly Version: 10.5.3700.0

Win32 Version: 10.5.0.268

CodeBase: file:///C:/Windows/assembly/GAC/CrystalDecisions.Enterprise.Framework/10.5.3700.0__692fbea5521e1304/CrystalDecisions.Enterprise.Framework.dll

-


                            • JIT Debugging **************

To enable just-in-time (JIT) debugging, the .config file for this

application or computer (machine.config) must have the

jitDebugging value set in the system.windows.forms section.

The application must also be compiled with debugging

enabled.

For example:

<configuration>

<system.windows.forms jitDebugging="true" />

</configuration>

When JIT debugging is enabled, any unhandled exception

will be sent to the JIT debugger registered on the computer

rather than be handled by this dialog box.

As per my display name I am rather new to this and am figuring there is some newbie mistake I'm making. To provide a little more detail the report is being passed a ticket number in which it uses as it's selection process to pull information out of an ACCESS 2007 database using the Microsoft Office 12.0 Access Database Engine OLE DB Provider.

ANY help is appreciated with this as I'm at my wits end trying to resolve it myself.

Thanks!

Chris

0 Kudos

Hi Chris,

There is a 2500 character limit and then forums removes formatting to preserve handling of the post. I edited you post and broke it up. Using the Preview tab will show you what others will. If no formatting then use a tool to count the words and past that much in.

Try Service Pack 1 for CR for VS 2008:

https://smpdl.sap-ag.de/~sapidp/012002523100009351512008E/crbasic2008sp1.exe

And get the distribution package also from our download page to see if that resolves the issue:

Thank you

Don

Former Member
0 Kudos

Don,

First off thank you very much for "repairing" my post. The character limit is noted for all further posts.

Second, I downloaded the newest redistributible and used that one on another laptop. I had already installed service pack 1 for crystal. I installed the program on this other laptop and it prints perfectly. So I went to the other laptop that was having the issue, installed the new redistributable and it still fails. Is there any walkthru that helps with uninstalling a previous redistributable that I could perform?

Once again thanks for the help and the cleanup of the post.

Chris

0 Kudos

Hi Chris,

Use Process Monitor from Microsoft and [Modules |https://smpdl.sap-ag.de/~sapidp/012002523100006252802008E/modules.zip]from here and compare working and non-working PC's.

You should be able to uninstall the runtime from the add/remove programs.

Thank you

Don

Answers (1)

Answers (1)

Former Member
0 Kudos

I apologize as I'm not sure why the formatting of my message did not hold thru to my post.......