0

I have .net 4.0 application which is crashing without any exception. When I install .net 4.5 on my machine, application did not crash. Mostly the app is crashing when idle for sometime. I tried to attach the application to debugger , but no help. Also i tried to attach the application to windbg.exe but that too did not help.

Actually my application is not using any function of .net 4.5.

In windows Event viewer , i can see the below log for the application crash. Event Log : An unhandled exception of type 'System.AccessViolationException' occurred. Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

If you have any experience with this, or have some useful tips or tools, let me know ! All kind of help is welcome.

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()

Possible function giving error 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);
                                }
        }
  • 3
    This question is hard to answer.. Did you get any informtion/error message at all? Just saying an application crashed is pretty much impossible to debug without more details! – Dave Aug 05 '13 at 11:38
  • @user2652946 What about the process, if you run the application and start task manager - does the process actually start? Does it run for a while and then just end? – Hexie Aug 05 '13 at 11:43
  • 2
    Try to use Debug Diagnostic Tool. It's a good starting point. http://www.microsoft.com/en-us/download/details.aspx?id=26798 – jlvaquero Aug 05 '13 at 11:46
  • Application is not giving any error message. It simply disappears :(. Also the process is up for sometime and after running for a while it crashes. It is happening frequently. – user2652946 Aug 05 '13 at 11:47
  • can you paste your code which is frequently throwing error.. – Ram Singh Aug 05 '13 at 11:53
  • An ExecutionEngineException is fatal and immediately terminates the app since 4.0. An access violation is the way it gets thrown. You'll need to look for unmanaged code in your app that corrupts the garbage collected heap. .NET 4.0 does have a known GC bug, fixed in 4.5 – Hans Passant Aug 05 '13 at 12:12

1 Answers1

0

Probably application uses some functions from net4.5. Application which uses v4.5 should check programatically is there .net4.5 installed on machine. Look at this question: How do I detect at runtime that .NET version 4.5 is currently running your code?

Community
  • 1
  • 1
tray2002
  • 188
  • 6