I am a developer trying to bring an old ASP.Net StoreFront website up to date enough so I can get it to run on my local machine. However, I get the issue:
[AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.]
I have tried:
- Disabling JIT
- Disabling compiler optimizations
- Forcing x86 platform target
- Commenting out all loaded assemblies
- I have updated to ASP.Net 4.5.2
Not only is the website broken on my computer, it is also broken on the production site with the same error.
The website I am working on is proprietary and I am bound by a confidentiality agreement, so I won't be able to post pieces of code. Does anyone have any suggestions?
Edit: I have access to the source code. If I run the project, it throws an error when it runs a method in the Global.asax.cs file. If I comment that out, it just throws the same error with no target.
Edit: 1. No DllImport or unsafe found in the code.
I'm using IISExpress and I can attach to the IISExpress process
[AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt. AspDotNetStorefront.Global.InitializeComponent() in c:\Dev\Web\App_Code\Global.asax.cs:222] AspDotNetStorefront.Global..ctor() in c:\Dev\Web\App_Code\Global.asax.cs:35 ASP.global_asax..ctor() in c:\AppData\Local\Temp\Temporary ASP.NET Files\root\47c1f925\38c0005\App_global.asax.inuh90ct.0.cs:0
[TargetInvocationException: Exception has been thrown by the target of an invocation.] System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0 System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +86 System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +230 System.Activator.CreateInstance(Type type, Boolean nonPublic) +67 System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1051 System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +215 System.Web.HttpApplicationFactory.FireApplicationOnStart(HttpContext context) +8984344 System.Web.HttpApplicationFactory.EnsureAppStartCalled(HttpContext context) +136 System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +92 System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +289]
This is the error I get if I comment out the function call currently being pointed to as the source:
Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
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 is corrupt.
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 is corrupt.]
System.Web.Mobile.ErrorHandlerModule..ctor() +0
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +86
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +230
System.Activator.CreateInstance(Type type, Boolean nonPublic) +67
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1051
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111
System.Web.Configuration.Common.ModulesEntry.Create() +39
System.Web.Configuration.HttpModulesSection.CreateModules() +164
System.Web.HttpApplication.InitModules() +28
System.Web.HttpApplication.InitInternal(HttpContext context, HttpApplicationState state, MethodInfo[] handlers) +729
System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +298
System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +107
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +289