.net 4.0应用程序崩溃意外无例外

时间:2013-08-05 11:36:14

标签: .net .net-4.0 .net-4.5

我有.net 4.0应用程序崩溃,没有任何异常。当我在我的机器上安装.net 4.5时,应用程序没有崩溃。大多数情况下,应用程序在闲置一段时间后会崩溃。 我试图将应用程序附加到调试器,但没有帮助。 此外,我试图将应用程序附加到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()             {                 尝试                 {

                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);
                                }
        }

1 个答案:

答案 0 :(得分:0)

可能应用程序使用net4.5中的一些功能。使用v4.5的应用程序应以编程方式检查机器上是否安装.net4.5。看看这个问题:How do I detect at runtime that .NET version 4.5 is currently running your code?

相关问题