尝试读取或写入受保护的内存

本文关键字:受保护 内存 读取 | 更新日期: 2023-09-27 17:54:41

我是一名试图引入旧ASP的开发人员。Net StoreFront网站是最新的,所以我可以让它在我的本地机器上运行。然而,我得到了一个问题:

[AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.]

我试过:

  • 禁用JIT
  • 禁用编译器优化
  • 强制x86平台目标
  • 注释掉所有加载的程序集
  • 我已更新到ASP。净额4.5.2

我的电脑上的网站不仅坏了,生产网站也坏了,出现了同样的错误。

我正在工作的网站是专有的,我受保密协议的约束,所以我不能发布代码。有人有什么建议吗?

编辑:我可以访问源代码。如果我运行该项目,当它运行Global.asax.cs文件中的方法时,它会抛出一个错误。如果我对此进行评论,它只是在没有目标的情况下抛出了相同的错误。

编辑:1。在代码中找不到DllImport或unsafe。

  1. 我正在使用IISExpress,我可以连接到IISExpression进程

    [AccessViolationException:试图读取或写入受保护的内存。这通常表明其他内存已损坏。AspDotNetStorefront。全球的c:''Dev''Web''App_Code''Global.asax.cs:222]中的InitializeComponent((AspDotNetStorefront。全球的c:''Dev''Web''App_Code''Global.asax.cs:35中的ctor((c:''AppData''Local''Temp''Temporary ASP中的ASP.global_asax.actor((。NET Files''root''47c1f925''38c0005''App_global.asax.inuh90ct.0.cs:0

    [TargetInvocationException:调用的目标引发了异常。]系统RuntimeTypeHandle。CreateInstance(RuntimeType类型、布尔publicOnly、布尔noCheck、布尔canBeCached、RuntimeMethodHandle和ctor、布尔NeedSecurityCheck(+0系统运行时间类型。CreateInstanceSlow(仅布尔publicOnly,布尔fillCache(+86系统运行时间类型。CreateInstanceImpl(布尔publicOnly,布尔skipVisibilityChecks,布尔fillCache(+230系统激活器。CreateInstance(类型类型,布尔非公共(+67系统运行时间类型。CreateInstanceImpl(BindingFlags bindingAttr,Binder Binder,Object[]args,CultureInfo区域性,Object[]activationAttributes(+1051系统激活器。CreateInstance(类型类型、BindingFlags bindingAttr、Binder Binder、Object[]args、CultureInfo区域性、Object[]activationAttributes(+111系统网状物HttpApplicationFactory。GetSpecialApplicationInstance(IntPtr appContext,HttpContext上下文(+215系统网状物HttpApplicationFactory。FireApplicationOnStart(HttpContext上下文(+8894344系统网状物HttpApplicationFactory。EnsureAppStartCalled(HttpContext上下文(+136系统网状物HttpApplicationFactory。GetApplicationInstance(HttpContext上下文(+92系统网状物HttpRuntime。ProcessRequestInternal(HttpWorkerRequest wr(+289]

如果我注释掉当前被指为源的函数调用,这就是我得到的错误:

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

尝试读取或写入受保护的内存

解决方案:ASPDNSF 7.0与ASP不兼容。净>2.0

http://forumarchive.vortx.com/threads/26485-Attempted-to-read-or-write-protected-memory.html最后一次

http://knowledge.3essentials.com/web-hosting/article/612/ERROR-Attempted-to-read-or-write-protected-memory.html

他们都指向asp.net 3.5 sp1和.net 3.5 sp1,这就是导致尝试读取的原因。。。。。错误

  1. 正如@JonSaunders在评论中暗示的那样,这似乎是对本地代码进行不当调用的结果。这将是检查的第一个地方——在解决方案中查找[DllImportunsafe以查找潜在的问题点。例如,当使用非线程安全的非托管库时,我看到了此错误弹出
  2. 更重要的是,将调试器附加到w3wp.exe IIS工作进程,在构造函数中的第一条语句处设置断点,访问有问题的页面,然后开始逐步执行。使用此项可以找出导致访问冲突的一个或多个调用

若要将调试器附加到w3wp,您必须确保以管理员身份运行Visual Studio,并且必须在网站部署到的计算机上运行它。此过程应该让您更好地了解导致AccessViolation的原因,并允许更好地进行研究/提问。

相关文章: