【发布时间】:2013-08-05 11:36:14
【问题描述】:
我有 .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()
可能的函数给出错误 私人无效 CreateWndAndMsgLoopThreadFunction() { 尝试 {
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);
}
}
【问题讨论】:
-
这个问题很难回答。你有没有收到任何信息/错误信息?如果没有更多细节,仅仅说应用程序崩溃几乎是不可能调试的!
-
@user2652946 如果您运行应用程序并启动任务管理器,那么进程会怎样——该进程是否真的启动了?它会运行一段时间然后结束吗?
-
尝试使用调试诊断工具。这是一个很好的起点。 microsoft.com/en-us/download/details.aspx?id=26798
-
应用程序没有给出任何错误信息。它只是消失了:(。此外,该进程已经启动了一段时间,运行一段时间后它崩溃了。它经常发生。
-
你能粘贴你经常抛出错误的代码吗..