473,387 Members | 1,541 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

System.AccessViolation Exception attempted to read or write protected memory.

Hi

I am a newbie to ASP.NET. I developed a web page (project type is web application) and I keep getting this error.

B]Error message :
"System.AccessViolation Exception attempted to read or write protected memory. this is often an indication that other memory is corrupt.... "[/b]

These are all the platform info :

Visual Studio 2005 (VB.NET) and ASP.NET 2.0.
I m using Microsoft.NET provider for ORACLE (System.data.Oracleclient).
I am using Microsoft Enterprise Library version 3.1 (May 2007) Data Access Application block for database operations.
The backend database is ORACLE 10g ver 10.2 and ORACLE client is 9.2 on the web server.
The webserver resides on a Windows 2000 server.


I keep getting this error pretty often on page load (where I make a database call). Sometimes the error does not show up and the page loads properly. Sometimes the error goes away after a period of time, but for most parts, the page literally becomes non-responsive after receving this error listed below. This literally cripples the web page I developed. I am able to bring the page back up and load it properly by restarting IIS. One more thing is this error mainly shows up only on the server and not on my local development machine (running XP Pro). Everything seems to work fine on my local machine until I deploy this page and run it on the server.

Error message :
"System.AccessViolation Exception attempted to read or write protected memory. this is often an indication that other memory is corrupt.... "


then a long list of functions related to database calls. My code script is given below : Specifically it fails (sometimes) at the point where I make the db.ExecuteScalar call. Please note that this error does not show up all the time, sometimes the page loads without any problems and with the correct value returned by ExecuteScalar.


Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim sql As String
Dim sEom As String

Try
If Not Page.IsPostBack Then
Dim db As Database = DatabaseFactory.CreateDatabase("DataSource")
'Get the financial period
sql = "select fin_period from fin_cal" ' this returns only one row
Using dbCommand As DbCommand = db.GetSqlStringCommand(sql)
sEom = CType(db.ExecuteScalar(dbCommand), String)
lblFinper.Text = sEom.ToString.Trim

If Not (dbCommand Is Nothing) Then
dbCommand.Dispose()
End If

End Using
End If

Catch ex As System.Data.OracleClient.OracleException
lblMessage.Text = "Database Error."
Response.Write(ex.ToString)

Catch ex As Exception
lblMessage.Text = "System Error."
Response.Write(ex.ToString)

End Try

End sub

Could anyone help me out, please ? It is critical that I make this work. I have also posted my code below. Please let me know whether I am making any mistake in code or in the way I am making Microsoft Enterprise Library Data Access application block calls. Your help on this would be greatly appreciated and a lifesaver for me!!

Thanks in advance.
Nov 7 '08 #1
3 6894
Plater
7,872 Expert 4TB
Is there any reason why you use the biztalk enterprize dll (namespace) to access the database instead of the standard OleDbConnection ?
Nov 7 '08 #2
Is there any reason why you use the biztalk enterprize dll (namespace) to access the database instead of the standard OleDbConnection ?
Hi

I was made to believe (by looking up articles online, Microsoft site, my personal developers network) that the enterprise dll follows the Microsoft best practices and patterns and also saves the developer coding time as shown below :

The Data Acccess Application Block (DAAB) solves databases problems by providing a simple, streamlined interface for accessing data and by abstracting out provider information into a separate configuration file. The DAAB provides a number of methods for accessing data, but the jist is that such data access can be done in one line of code. This is because the DAAB's methods wrap the several lines of code needed to access data. Rather than having to write the 5-10 lines of code (as we saw above), the DAAB simplifies code down to a line or 2.

Do you think I was not right in my approach of using MS Enterprise library DAAB for database operations?
Nov 7 '08 #3
Plater
7,872 Expert 4TB
Well the DLL appears to be mostly a COM dll and not managed? I don't knot, this is the first I have ever heard of it
Nov 10 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: XJ | last post by:
Hi experts, i try to use vb.net 2005 call dll, then give me "Attempted to read or write protected memory.This is often an indication that other memory is corrupt". i have chk some message others...
1
by: ianyian | last post by:
Hi experts, i try to use vb.net 2005 call C++ dll, then give me "Attempted to read or write protected memory.This is often an indication that other memory is corrupt". i have chk some message...
2
by: James Arnold | last post by:
I am getting the following error message in my WinForms project: --- An unhandled exception of type 'System.AccessViolationException' occurred in System.Windows.Forms.dll Additional...
2
by: Pieter | last post by:
Hi, Since 10 days (the first time was the 10th of november) I have some weird exception happening in an application here: All (except 1 of the total of 5) users had this error now 1 of 2 times...
6
by: Sugandh Jain | last post by:
Hi, I am getting the error message Attempted to read or write protected memory. This is often an indication that other memory is corrupt. It was not coming until yet, for around 2 months. Now,...
1
by: Sudhan | last post by:
hi i am trying to write excel using VB.net but when i open oExcel.Workbooks.Open the application error: Attempted to read or write protected memory. This is often an indication that other memory...
5
by: Henry Stock | last post by:
I am trying to understand the following error: Any thing you can tell me about this is appreciated. Security Exception Description: The application attempted to perform an operation not allowed...
0
by: mikomty | last post by:
I get the following error message when trying to write/read to a Data Acquisition Switch Unit 34970A using IEEE. Attempted to read or write protected memory issue. This is often an indication that...
3
by: maneshborase | last post by:
Hi friends, I am facing one serious problem in my application. I am trying to open dicom image file (.dcm) has size around 400 MB. But I am getting and unhandy exceptions, Some time, ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.