Hi For to train with ASP.NET V2 , I have to migrate an web application. It's picture galery. But sometimes I have got this errors : Attempted to read or write protected memory. This is often an indication that other memory has been corrupted. Description: An
unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.AccessViolationException: Attempted to read or write
protected memory. This is often an indication that other memory has been corrupted. Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified
using the exception stack trace below. Stack Trace: [AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory has been corrupted.] System.EventHandler.Invoke(Object sender, EventArgs e) +0 System.Web.UI.Control.OnLoad(EventArgs
e) +87 System.Web.UI.Control.LoadRecursive() +66 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2835 -------------------------------------------------------------------------------- Version
Information: Microsoft .NET Framework Version:2.0.40420.0; ASP.NET Version:2.0.40420.0 Thanks for your help.
Hi, Are you using any custom controls? Can you please get the full stack trace (e.g. view->source in the browser menu when requesting the page locally)? The error often indicates an AV in unmanaged code that your app might be calling into.. thanks Gjergji
This posting is provided "AS IS" with no warranties, and confers no rights.
Your problem is genuine. And since it is problem , it has a soluton too. The solution lies with you ;only you need to look at it in a different view. I have faced the similar problem and took me weeks to solve it.
The main cause behind it lies to the highly enhanced security features of .NET framework 2.0 over .NET 1.1. It has imposed several restiction , policies and permission sets for accessing the data from the web application, It uses full trust as well as partial
trust.
1) If you try to access the data you don't have permission too or if the source is not trusted it gives the above exception. You not only have to give permission to your application to access the source BUT you need to make the source as trusted one too.
2)Also, the other main cause is that , if you try to read the data that is not available, it gives the above exception.
So its time now to revise your concepts about CAS and permissions in visual studio.NET 2005 which is highly advanced than .NET 1.1.
I had got this error message when i was trying to retrieve the servername from the ini file through GetPrivateProfileString. But then i had rights to the file. Cant understand wat the problem is. Kindly help.
We've got the same exception ("Attempted to read or write protected memory. This is often an indication that other memory has been corrupted.") after we have migrated our ASP.NET application from Framework 1.1 to 2.0. The error occurs when application calls
method from external DLL written in C++. DLL itself works with file systems and COM objects (such as Word Automation object).
We have tested different options. For the moment:
1) Application is impersonated - aspnet_wp.exe is launched under user account with administrative rights.
2) This user account has Full Control permission on all affected files and folders as well as on used COM objects.
3) As suggested on other forums, compiler optimisation is turned off.
4) All methods in C# class which call methods from DLL are marked with [SecurityPermission(SecurityAction.Assert, Unrestricted = true)] attribute.
But anyway we've got "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." exception at a certain method call. On ASP.NET 1.1 everything works fine. Does anybody have any idea how to solve the issue?
Microsoft also released a hotfix (July 2nd, 2007) to prevent the error "Attempted to read or write protected memory" that has been plaguing the .NET 2.0 platform for some time now.
wesleymichel
Member
669 Points
153 Posts
Attempted to read or write protected memory. This is often an indication that other memory has be...
Aug 25, 2004 10:40 AM|LINK
gstasa
Member
230 Points
44 Posts
AspNetTeam
Re: Attempted to read or write protected memory. This is often an indication that other memory ha...
Sep 02, 2004 09:31 PM|LINK
blbirajdar
Member
4 Points
2 Posts
Re: Attempted to read or write protected memory. This is often an indication that other memory ha...
Dec 23, 2006 04:04 AM|LINK
Your problem is genuine. And since it is problem , it has a soluton too. The solution lies with you ;only you need to look at it in a different view. I have faced the similar problem and took me weeks to solve it.
The main cause behind it lies to the highly enhanced security features of .NET framework 2.0 over .NET 1.1. It has imposed several restiction , policies and permission sets for accessing the data from the web application, It uses full trust as well as partial trust.
1) If you try to access the data you don't have permission too or if the source is not trusted it gives the above exception. You not only have to give permission to your application to access the source BUT you need to make the source as trusted one too.
2)Also, the other main cause is that , if you try to read the data that is not available, it gives the above exception.
So its time now to revise your concepts about CAS and permissions in visual studio.NET 2005 which is highly advanced than .NET 1.1.
For details click the link below http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetsec/html/foundstone.asp
Go thro it docs and decide which permission your application requires and implement it.
Best of Luck.
mail me a thank you if you are benefitted by this post.
Balaji Birajdar
Software Engineer, Pune
veena_ramdas
Member
8 Points
4 Posts
Re: Attempted to read or write protected memory. This is often an indication that other memory ha...
Apr 19, 2007 10:16 AM|LINK
Dmitry Gresev
Member
2 Points
1 Post
Re: Attempted to read or write protected memory. This is often an indication that other memory ha...
May 30, 2007 10:47 AM|LINK
We've got the same exception ("Attempted to read or write protected memory. This is often an indication that other memory has been corrupted.") after we have migrated our ASP.NET application from Framework 1.1 to 2.0. The error occurs when application calls method from external DLL written in C++. DLL itself works with file systems and COM objects (such as Word Automation object).
We have tested different options. For the moment:
1) Application is impersonated - aspnet_wp.exe is launched under user account with administrative rights.
2) This user account has Full Control permission on all affected files and folders as well as on used COM objects.
3) As suggested on other forums, compiler optimisation is turned off.
4) All methods in C# class which call methods from DLL are marked with [SecurityPermission(SecurityAction.Assert, Unrestricted = true)] attribute.
But anyway we've got "Attempted to read or write protected memory. This is often an indication that other memory is corrupt." exception at a certain method call. On ASP.NET 1.1 everything works fine. Does anybody have any idea how to solve the issue?
philipd
Member
2 Points
1 Post
Re: Attempted to read or write protected memory. This is often an indication that other memory ha...
Jun 13, 2007 01:52 AM|LINK
Hi Dmitry,
Did you figure this out? We have the same exact issue and would love to hear the solution?
Thanks,
- Phil.
brianphilpot
Member
89 Points
19 Posts
Re: Attempted to read or write protected memory. This is often an indication that other memory ha...
Jul 03, 2007 04:05 PM|LINK
I was getting this same exact message. Cryptic.
The error came up when my aspx page attempted to execute an OleDBCommand against Oracle 10g client.
Then I realized that I was missing the command parameter that was specified in the query.
Looks like instead of giving you a pretty message, you get this ugly one.
Hope This Helps,
Brian
sam_de_diacre
Member
2 Points
1 Post
Re: Attempted to read or write protected memory. This is often an indication that other memory ha...
Jul 10, 2007 05:39 PM|LINK
Hi Dmitry and philipd,
I also have the same problem of my aplication calling a DLL, do you by that time solved the problem?
regards,
Sami
gogliogi
Member
6 Points
3 Posts
Re: Attempted to read or write protected memory. This is often an indication that other memory ha...
Jul 26, 2007 03:28 PM|LINK
Hi guys,
did you try to use Microsoft driver for OLE (MSDAORA) instead of Oracle driver ?
it solved the issue for me:
Gogliogi
gogliogi
Member
6 Points
3 Posts
Re: Attempted to read or write protected memory. This is often an indication that other memory ha...
Jul 27, 2007 07:01 AM|LINK
Microsoft also released a hotfix (July 2nd, 2007) to prevent the error "Attempted to read or write protected memory" that has been plaguing the .NET 2.0 platform for some time now.
But it did NOT worked in my case.
The hotfix can be downloaded from http://connect.microsoft.com/VisualStudio/Downloads/DownloadDetails.aspx?DownloadID=6003
Gogliogi