簡體   English   中英

調試開始時出現AccessViolationException

[英]AccessViolationException when debug starts

我的應用遇到了一個真正的問題,無法解決。 大約30%的時間,當我按F5鍵在Visual Studio上調試應用程序時,在System.Windows.Forms.dll上獲得了AccessVioltaionException。

真正奇怪的是,我的應用程序是WPF,並且沒有對Windows Forms的引用,也沒有使用任何可以引用它的庫。 異常發生在調試會話的開始,並且我的第一行代碼甚至沒有在異常之前執行。 它僅在調試時發生在我的應用程序上(如果我在Visual Studio之外啟動我的應用程序則永遠不會發生),並且它發生的時間少於一半。 有時,為了使我的應用程序運行,我不得不嘗試連續調試4或5次。

我已經在網上搜索過,卻找不到任何信息或遇到相同問題的任何人。 自幾個月以來,我已經有了這個例外。

您認為導致此異常的原因是什么?我該怎么辦才能找到問題的根源?

我在這里發布了Visual Studio異常的打印屏幕。 它是葡萄牙語,但是我想您會從圖像中了解它。 異常打印屏幕


編輯:我將異常詳細信息復制到剪貼板,結果文本如下:

System.AccessViolationExceptionnãofoi manipulada HResult = -2147467261消息=保留了保護性的備忘錄。 丹麥的存在之外,還有其他的存在。 Source = System.Windows.Forms StackTrace:em System.Windows.Forms.UnsafeNativeMethods.SendMessage(HandleRef hWnd,Int32 msg,IntPtr wParam,IntPtr lParam)em System.Windows.Forms.Control.SendMessage(Int32 msg,Int32 wparam,IntPtrtr lparam)em System.Windows.Forms.Form.UpdateWindowIcon(Boolean redrawFrame)em System.Windows.Forms.Form.CreateHandle()em System.Windows.Forms.Control.get_Handle()em Microsoft.VisualStudio.HostingProcess.HostProc.RunParkingWindowThread ()em System.Threading.ExecutionContext.RunInternal(ExecutionContextexecutionContext,ContextCallback回調,對象狀態,布爾值saveSyncCtx)em System.Threading.ExecutionContext.Run(ExecutionContext執行上下文,ContextCallback回調,對象狀態,布爾值saveSyncCtx)em System.Threading.ExecutionContext .Run(ExecutionContext executeContext,ContextCallback回調,對象狀態)em System.Threading.ThreadHelper.ThreadStart()InnerException:

禁用Visual Studio宿主進程后,現在AccessViolationException引發在應用程序窗口的Show()方法上。 這是異常的statck跟蹤:

*System.AccessViolationException não foi manipulada
  HResult=-2147467261
  Message=Tentativa de ler ou escrever na memória protegida. Isto é normalmente uma indicação de que existe outra memória danificada.
  Source=WindowsBase
  StackTrace:
       em MS.Win32.UnsafeNativeMethods.CriticalSetWindowTheme(HandleRef hWnd, String subAppName, String subIdList)
       em System.Windows.Interop.HwndSource.Initialize(HwndSourceParameters parameters)
       em System.Windows.Window.CreateSourceWindow(Boolean duringShow)
       em System.Windows.Window.ShowHelper(Object booleanBox)
       em ASilva.Gamer.Dialogs.ProgressWindow.Show(String title, String text) em C:\Users\ASilva\Documents\Visual Studio 2015\Projects\Gamer\Gamer\Dialogs\ProgressWindow.xaml.cs:line 124
       em ASilva.Gamer.App.StartupApplication(IEnumerable`1 args) em C:\Users\ASilva\Documents\Visual Studio 2015\Projects\Gamer\Gamer\App.xaml.cs:line 634
       em ASilva.Gamer.App.Application_Startup(Object sender, StartupEventArgs e) em C:\Users\ASilva\Documents\Visual Studio 2015\Projects\Gamer\Gamer\App.xaml.cs:line 1263
       em System.Windows.Application.OnStartup(StartupEventArgs e)
       em ASilva.Gamer.App.OnStartup(StartupEventArgs e) em C:\Users\ASilva\Documents\Visual Studio 2015\Projects\Gamer\Gamer\App.xaml.cs:line 499
       em System.Windows.Application.<.ctor>b__1_0(Object unused)
       em System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       em System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       em System.Windows.Threading.DispatcherOperation.InvokeImpl()
       em System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
       em System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       em MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
       em System.Windows.Threading.DispatcherOperation.Invoke()
       em System.Windows.Threading.Dispatcher.ProcessQueue()
       em System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       em MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       em MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       em System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
       em System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
       em System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
       em MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       em MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       em System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       em System.Windows.Application.RunDispatcher(Object ignore)
       em System.Windows.Application.RunInternal(Window window)
       em ASilva.Gamer.App.Main()
  InnerException:* 

我沒有對Windows窗體的任何引用

好吧,不是你。 但是,當您調試應用程序時,您確實確實使用了Winforms,但堆棧跟蹤並不存在。 不是您的代碼,而是調試器使用的代碼來創建該依賴關系。 易於刪除,請使用“項目”>“屬性”>“調試”選項卡>取消選中“啟用Visual Studio托管過程”選項。

請記住,這不是Winforms錯誤。 正是金絲雀在煤礦中死亡。 托管過程使用SystemEvents類。 為了獲取通知並觸發其事件,該類需要創建一個窗口。 它是隱藏的,僅用於獲取通知。

死亡的代碼是永遠不會消失的代碼,設置窗口的圖標(通常在左上角可見) 絕不會引發此類異常。 程序的名稱給出了某種提示,由關心窗戶外觀的人擁有。 這是由實用程序引起的崩潰,這些實用程序會更改窗口鑲邊的外觀。

您需要修理機器。 很碎。

通過禁用托管過程來mp行。

暫無
暫無

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

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