C#.NET 4.0应用程序随机崩溃 [英] C# .NET 4.0 application crashes randomly
问题描述
移至.net 4.0之后,我们的应用程序出现了奇怪的崩溃.
深入研究之后,我们可以得到低于堆栈跟踪的信息:
RealNative RealNativeWindowCopy DispatchMessageW 味精 msg 在 . ( 形式 在 . () . . ( 状态 在 . . ( executionContext 回调 状态 ignoreSyncCtx 在 . . ( executionContext 回调 状态 在 . . ()
尝试{
MyNativeWindow ; 新 MyNativeWindow CreateParams cp = 新 (); 标题 . ; ClassName . ; nw UserWndProc ( ); CreateHandle cp m_hWnd nw . ; //非常重要! //检查句柄是否为空 if ( m_hWnd ==. ) { MessageBox 显示 "Exception" . ); } while ( true) { // //if i'm getting true that means i've got WM_QUIT. // bool bReply = LocalModalMessageLoop(null); if (bReply ==true ) return; } }
Though we are not sure if this is the exact function as the application has huge code and we also have unmanaged code. So from where the exception is thrown is not very clear.
Any kind of help is welcome!
预先感谢!
Have you tried to catch the unhandled exception using either Application.UnhandledException or AppDomain.UnhandledException events? These events are raised whenever there is an unhandled exception (like your crash). You can subscribe to those events and check the event arguments for information like Callstack.
我希望这会有所帮助.
Hi,
We're having strange crashes in the our application after moving to .net 4.0.
My C# application disappears randomly without any exception.The old version was running with .net 3.5 without any crashes, but now that we moved to the .net 4.0 it started crashing randomly.
after digging down we could get below the stacktrace:
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()
The possible function which is causing issue is like :
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("Exception", "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;
}
}
Though we are not sure if this is the exact function as the application has huge code and we also have unmanaged code. So from where the exception is thrown is not very clear.
Any kind of help is welcome!
Thanks in advance!
Have you tried to catch the unhandled exception using either Application.UnhandledException or AppDomain.UnhandledException events? These events are raised whenever there is an unhandled exception (like your crash). You can subscribe to those events and check the event arguments for information like Callstack.
I hope this helps.
这篇关于C#.NET 4.0应用程序随机崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!