我有 .net 4.0 应用程序,它毫无例外地崩溃。当我在我的机器上安装 .net 4.5 时,应用程序没有崩溃。大多数情况下,应用程序在空闲一段时间后会崩溃。我试图将应用程序附加到 debugger ,但没有帮助。我也尝试将应用程序附加到windbg.exe,但这也没有帮助。
实际上我的应用程序没有使用 .net 4.5 的任何功能。
在 Windows 事件查看器中,我可以看到应用程序崩溃的以下日志。事件日志:发生“System.AccessViolationException”类型的未处理异常。附加信息:试图读取或写入受保护的内存。这通常表明其他内存已损坏。
如果您对此有任何经验,或者有一些有用的提示或工具,请告诉我!欢迎各种帮助。
堆栈跟踪:
at RealNative.RealNativeWindowCopy.DispatchMessageW(MSG& msg)
at RealNative.RealNativeWindowCopy.LocalModalMessageLoop(Form form)
at RealNative.RealNativeWindowCopy.CreateWndAndMsgLoopThreadFunction()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
可能的函数给出错误 private void CreateWndAndMsgLoopThreadFunction() { try {
MyNativeWindow nw;
nw = new MyNativeWindow();
CreateParams cp = new CreateParams();
cp.Caption = this.m_winTitle;
cp.ClassName = "!!" + this.m_classname; // i've modified the treatment so if the classname starts with !!, it will be registered undet that name
nw.UserWndProc = new UserWndProc(UserWndProcWrapper);
nw.CreateHandle(cp);
m_hWnd = nw.Handle; // very important !
// check if handle is null
if (m_hWnd == IntPtr.Zero)
{
MessageBox.Show("VishException in CreateWndAndMsgLoopThreadFunction", "Error", MessageBoxButtons.OKCancel);
}
while (true)
{
//
// if i'm getting true that means i've got WM_QUIT.
//
bool bReply = LocalModalMessageLoop(null);
if (bReply == true)
return;
}
#if _SHOW_DBG_MSGS
MDBGLogger.MDBGLogger.AlwaysLine("Exiting messageLoop");
#endif
}
catch (Exception e)
{
MessageBox.Show("VishException in CreateWndAndMsgLoopThreadFunction", "Error", MessageBoxButtons.OKCancel);
}
}