簡體   English   中英

嘗試讀取或寫入受保護的內存

[英]Attempted to Read or Write protected memory

我是一名開發人員,試圖將舊的ASP.Net StoreFront網站更新為最新版本,以便可以在本地計算機上運行它。 但是,我遇到了問題:

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

我努力了:

  • 禁用JIT
  • 禁用編譯器優化
  • 強制x86平台目標
  • 注釋掉所有已加載的程序集
  • 我已經更新到ASP.Net 4.5.2

網站不僅在我的計算機上損壞,而且在生產站點上也被損壞,並出現相同的錯誤。

我正在使用的網站是專有網站,並且我受保密協議的約束,因此我將無法發布代碼段。 有沒有人有什么建議?

編輯:我可以訪問源代碼。 如果我運行該項目,則在運行Global.asax.cs文件中的方法時會引發錯誤。 如果我將其注釋掉,它只會拋出相同的錯誤而沒有目標。

編輯:1.在代碼中找不到DllImport或不安全。

  1. 我正在使用IISExpress,可以附加到IISExpress進程

    [AccessViolationException:嘗試讀取或寫入受保護的內存。 這通常表明其他內存已損壞。 c:\\ Dev \\ Web \\ App_Code \\ Global.asax.cs:222中的AspDotNetStorefront.Global.InitializeComponent():222] c:\\ Dev \\ Web \\ App_Code \\ Global.asax.cs:35中的AspDotNetStorefront.Global..ctor() c:\\ AppData \\ Local \\ Temp \\ Temporary ASP.NET Files \\ root \\ 47c1f925 \\ 38c0005 \\ App_global.asax.inuh90ct.0.cs:0中的ASP.global_asax..ctor()

    [TargetInvocationException:調用的目標引發了異常。] System.RuntimeTypeHandle.CreateInstance(RuntimeType類型,布爾publicOnly,布爾noCheck,布爾&canBeCached,RuntimeMethodHandle&ctor,布爾&bNeedSecurityCheck)+0 System.RuntimeType.CreateInstanceSlow(布爾publicOnly,布爾fillCache)+86 System.RuntimeType.CreateInstanceImpl(布爾publicOnly,布爾skipVisibilityChecks,布爾fillCache)+230 System.Activator.CreateInstance(類型,布爾非公共布爾)+67 System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr,活頁夾活頁夾,對象[ ] args,CultureInfo文化,Object [] activationAttributes)+1051 System.Activator.CreateInstance(類型,BindingFlags bindingAttr,活頁夾活頁夾,Object [] args,CultureInfo文化,Object [] activationAttributes)+111 System.Web.HttpApplicationFactory.GetSpecialApplicationInstance (IntPtr appContext,HttpContext上下文)+215 System.Web.HttpApplicationFactory.FireApplicationOnStart(Http 上下文上下文)+8984344 System.Web.HttpApplicationFactory.EnsureAppStartCalled(HttpContext上下文)+136 System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext上下文)+92 System.Web.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.Net> 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,並允許進行更好的研究/問題詢問。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM