Hi All,

I am using VB.net2005 and interop

Code snipnet:

Dim objpropsets As Test.PropAuto.Interop.PropertySets = Nothing

Dim objprops As Test.PropAuto.Interop.Properties = Nothing

Dim objprop As Test.PropAuto.Interop.Property = Nothing


objpropsets = CreateObject("Test.FileProperties")


Exception is occuring at objpropsets.Open(FileName). - Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Can you please help me in the same

Re: Visual Basic Interop and Upgrade Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Bruno Yu - MSFT


Based on your post, the error message is quite a common issue. It seems that you are developing the application with the unmanaged code Interop. I would like to provide you the suggestions as follows:

1. Most of the time you will not see this kind of an error with purely .NET code. The CLR was designed to avoid these situations with developer code. However, when you go beyond purely managed code, an invalid pointer is what causes this problem. This can happen when you pass a pointer to an API. If the pointer is null (the address is 0), you will almost always get this error (assuming the unmanaged code doesn't crash first). If the pointer contains an address value that is outside the allocated memory range for the app, or is in the range reserved for OS usage, then you will also get the error. Additionally, you can map memory with different access levels (actually, as a .NET programmer, you usually don't, but some other unmanaged code might). If your process doesn't have "read" access to that mapped memory range, you'll also get this error.

In short, most of the time it's a bug with your code trying to use unmanaged code (passing something by value instead of by ref, or passing a null pointer, or something to that effect), or it's a bug in a 3rd party unmanaged library (even possibly a driver depending on what kind of code we're interacting with here).

For further information, please take a look at the following thread and the above explanation is provided by Rob Teixeira :

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

2. In Visual Studio 2005, you can consider to set the Debugger as the following steps:

In VS menu, click Tools -> Options. In the Options panel, please choose Debugging -> General. Then please uncheck option "Suppress JIT optimization on module load (Managed Only).

Hope that can help you.

Re: Visual Basic Interop and Upgrade Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

Cherry W

Hi Rups11 & Bruno,

I am having the same issue with Rups11 when using VS.Net 2005 with Interop dll of Crystal Reports.

However, I cannot locate which pointer/ reference in the program to have such bad/null value.

One more supplementary information, the code is runnable without any problem in VS.Net 2003.

During upgrade, I don't make any big change to the code but just update the Project References to latest version.

Does Rups11 solve the issue

Any more suggestion

AxInterop.CRVIEWER9Lib.dll -> AxInterop.CrystalActiveXReportViewerLib11_5.dll

Interop.CRAXDRT.dll (v9)-> Interop.CRAXDRT.dll (v11)

Here is fragment of code:

Dim adoOracleDbConnection As OracleConnection

Dim adoOracleDbDataAdapter As OracleDataAdapter

Dim conn As String

Dim strSQL As String

Dim Report As New CRAXDRT.Report

Dim CrApp As New CRAXDRT.Application

Dim myXmldocument As New Xml.XmlDocument


myXmldocument.Load(Application.StartupPath & "/CRpath.xml")

conn = "connection_string"

adoOracleDbConnection = New OracleConnection(conn)

strSQL = Report_SQL

adoOracleDbDataAdapter = New OracleDataAdapter(strSQL, adoOracleDbConnection)

adoOracleDbDataAdapter.Fill(dataSet, "Main")

Report = CrApp.OpenReport(tempReportSource)'<---exception prompt here ocasionally


AxCRViewer11.ReportSource = Report


Catch x As Exception

Console.WriteLine("Form1_Load:" & x.Message & Chr(13) & (10) & x.StackTrace)

Exit Sub

End Try

Thanks and Regards,