none
C# .NET 4.0 application crashes randomly RRS feed

  • Question

  • 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!

    Wednesday, August 7, 2013 6:46 AM

All replies

  • 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.


    Please mark this post as answer if it solved your problem. Happy Programming!

    • Proposed as answer by Damon Bu - MSFT Friday, August 9, 2013 9:58 AM
    • Marked as answer by Damon Bu - MSFT Wednesday, August 14, 2013 1:18 AM
    • Unmarked as answer by vish912 Tuesday, August 27, 2013 8:55 AM
    Wednesday, August 7, 2013 11:13 AM
  • Hi vish912,

    I have not received your reply a few days.
    I am writing to check the status of the issue. What about this problem now?
    I will temporarily mark Adavesh's last response as an answer. You can unmark it if they provide no help.

    Regards,

    Damon


    Damon Bu - MSFT
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, August 13, 2013 8:53 AM
  • Hi Damon,

    This problem still persist :(.

    I have unmarked as the above response is not an answer to my problem. 

    Tuesday, August 27, 2013 8:55 AM