Attempted to read/write protected memory

S

sushant

Hi All,

I have one .net application, runs as service under localsystem
account. This application use dllimport to call a method of C dll,
which basically reads a huge file (1GB or more) and generate some xml
string as needed.This works fine most of the time but sometimes we see
exception "Attempted to read/write protected memory. This is often
indication that other memoyr is corrupt" when my app tries to read the
xml string. This is independent of file size as we see it for smaller
files as well. Please note that, dll access the files from network.
After 3-4 attempts, the error vanishes, and application runs properly.
Also we logged the XML string from C dll, just before return
statement, and it comes fine everytime. Probably i am doing something
wrong in implementation.

This exception comes more in vista than XP.

Please suggest.

regards,
hungrymind
www.hungrymind-concepts.com
 
N

not_a_commie

I had some problems recently where the .Net Filestream class would
have trouble with files larger than 60MB on a UNC path. You can Google
that for more info.

Does your C DLL return a file pointer? or a pointer of any kind? or a
handle of any kind? or just a string? What encoding is the string?

From that particular error I would guess that there is a bug in the C
DLL. Something in there allocated too little or there was an array out-
of-bounds access or something got used after it was deallocated.
 
I

Ignacio Machin ( .NET/ C# MVP )

Hi All,

I have one .net application, runs as service under localsystem
account. This application use dllimport to call a method of C dll,
which basically reads a huge file (1GB or more) and generate some xml
string as needed.This works fine most of the time but sometimes we see
exception "Attempted to read/write protected memory. This is often
indication that other memoyr is corrupt" when my app tries to read the
xml string. This is independent of file size as we see it for smaller
files as well. Please note that, dll access the files from network.
After 3-4 attempts, the error vanishes, and application runs properly.
Also we logged the XML string from C dll, just before return
statement, and it comes fine everytime. Probably i am doing something
wrong in implementation.

This exception comes more in vista than XP.

Please suggest.

regards,
hungrymindwww.hungrymind-concepts.com

Do y ou know where the error originate?
If it does come from the C dll then you will have a hardtime finding
the error (unless you have experience in C & the source code) ,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top