System.AccessViolationException Attempted to read or write protected memory ?
A common error always pop up when you run your .NET Application just like the following :
Error Details:
System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
The reasons and resolutions:
These are different solutions due to different case, Here I collect some of them which I have found:
0: First of all, telerik company has a solution for their products, maybe it is fit for your case:
so far we have found the following reasons for the exception:
* configuration/installation problems of the framework, VS.NET and/or SourceSafe/SourceGear (usually the SourceSafe/SourceGear installation is corrupted). Restarting of VS, IIS or the machine does not help;
* running 32-bit code which tries to call 64-bit one and vice versa (this appears on 64bit machines, i.e. 64-bit CPU, Windows or .NET 2.0 version).
SOLUTIONS This error message is still being investigated and other solutions may exist. In case you are able to fix the problem in some other way than the described below, please let us know, so that we can update the article.
- Try creating a new project - you should be able to use the Telerik controls in that project.
- If you are still using the beta version of VS2005, update to the latest official version and try again.
- A webserver with multiple worker processes may cause this inconsistency. The problem should disappear once the number of worker processes is set to 1.
- Ensure that the VS.NET addin works in SourceSafe/SourceGear works. You can do that by checking files in and out of your repository (try checking out a page before dropping a control and see if it works). Try uninstalling all copies of VSS that you may have on your machine and install the latest version only.
- If you use the 64bit version of .Net2, then review this Microsoft support article on switching from .NET1.x 32bit to .NET2 64bit: http://support.microsoft.com/default.aspx?scid=kb;en-us;894435, more importantly the ASP.NET 2.0, 32-bit version section and setting the 64bit Web Service to Prohibited.
- Simply copy and paste the controls' DLLs and XML files into the bin directory.
- If none of the above works, you may consider reinstalling the machine.
1: (for Oracle Exception) This happens sometime due to corrupt data in memory. To resolve it Please restart the application or restart the system.
2: I found the reason: I had installed a program called "Netlimiter" on the test server (used for testing the app with limmited bandwidth). It was en error in a nsl dll from that program that caused my problem. After uninstalling the program it worked fine.
However, I do not know why I only got the error with .Net 2.0 and not with 1.1.
/Nicolai
3: Issue Description: -- Getting following pop-up error when trying to drag and drop Microsoft Controls in Visual Studio 2005 design view
Resolution:
-- There was something wrong with the registration of VS packages. We reset those and it resolved the issue. -- We ran the following command from the C:\Program Files\Microsoft Visual Studio 8\Common7\IDE>devenv.exe /ResetSkipPkgs
-- We opened the existing project in Visual Studio 2005 and now we did not get the above error while dragging and dropping Microsoft and non-Microsoft Controls.
-- Tried closing and opening up the project again and still no issues.
(will continue to find more if possible)