locked
Application popup when closing application RRS feed

  • Question

  • Hi all,

    I'm working on a project, it contains 2 execute, one named Login.exe, another named Main.exe. These execute are using same source code and setting, just different entry point.

    But recently, when closing Login.exe, it will randomly encounter an error:

    Application popup:
    Login.exe - Application Error :
    The instruction at "0x0ecf10bd" referenced memory at "0x0ed10810". The memory could not be "read".

    This message box just contain a OK button, sometime when I click ok, the Login.exe will be terminated, but sometime, it will hang, and just need use task killer to kill it (and need to "kill" several time)

    Here is the code when I exit the Login.exe:

    System.Diagnostics.Process.Start("Main.exe", _User.Uid)
    Environment.Exit(0)
    
    The code when I exit Main.exe:

    System.Diagnostics.Process.Start("Login.exe", _uUser.Uid)
    Environment.Exit(0)
    
    We have tried following "solution", but no luck:

    Change the hardware
    Replace Adobe Flash with PNG
    Restart pc everyday

    Do anyone have any suggestion?

    • Edited by Cerberus Wang Wednesday, February 2, 2011 2:24 AM formatting issue
    Wednesday, February 2, 2011 2:22 AM

Answers

  • I'm sorry for the late reply, after a week of testing, we find out the problem is the crystal report control.

    GC cannot release the crystal report control before we init it again, and it make the memory address corrupt (or should I said changed?), so the windows marked that memory address cannot be read (cos using by another instance)

    Now we call crystal report control to dispose every time when we kill the Login.exe.

    At the end, thanks eric and Adavash for help.

    • Marked as answer by Cerberus Wang Tuesday, March 8, 2011 6:22 AM
    Tuesday, March 8, 2011 6:22 AM

All replies

  • Where are you adding your exit logic in your Login.exe?

    Subscribe to the Application.ApplicationExit event and in the handler start the other process. Call Application.Exit() on closing the the application.

    -----------------------------------

    Please mark the post answered, if it solved your problem !!!

     

    Wednesday, February 2, 2011 3:10 AM
  • I put those exit logic in a class control, and I can't use Application.ApplicationExit to start it, cause some case I don't need to start other process, like I need to shut down the pc, I just need to exit the program and restart the pc.

    The code should like this:

    select case buttonid
     case 1
     System.Diagnostics.Process.Start("Main.exe", _uUser.UID)
     Environment.Exit(0)
     case 2
     Environment.Exit(0)
     ' Shut down pc
     case 3
     Environment.Exit(0)
     ' Restart pc
    end select
    
    And should I change all Environment.Exit(0) to Application.Exit? (My program is application program)

    Wednesday, February 2, 2011 3:36 AM
  • Correct. In case 1, Instead of Environment.Exit, call Application.Exit() and it should solve your problem.

    Regards,
    Adavesh

    -----------------------------------

    Please mark the post answered, if it solved your problem. Happy Programming !!!

    Wednesday, February 2, 2011 4:01 AM
  • Sorry for the late reply, after a series of testing, seems it is the memory problem, those machine haven't enable the virtual memory, after we set the virtual memory on, the problem seems solve (well, need more time to prove this).

    And I didn't change the Environment.Exit to Application.Exit yet, so it seems not related to programming issue, and thanks Adavesh advance.

    • Marked as answer by Cerberus Wang Wednesday, February 9, 2011 3:19 AM
    • Unmarked as answer by Cerberus Wang Monday, February 21, 2011 1:39 AM
    Wednesday, February 9, 2011 3:19 AM
  • After a few week I've change the virtual memory setting, this nightmare still exist.

    I have followed Adavesh suggestion to change to Application.Exit, but maybe my program was called by process

    System.Diagnostics.Process.Start("Main.exe"
    
    )
    

    When I use the application.exit, in some case, the program still remain, so I have changed back to Environment.Exit

    And I have grab the memory dump after the program crash

     

    >	ntdll.dll!_KiFastSystemCallRet@0() 	
     	ntdll.dll!_NtDelayExecution@8() + 0xc bytes	
     	kernel32.dll!_SleepEx@8() + 0x51 bytes	
     	mscorwks.dll!EESleepEx() + 0x28 bytes	
     	mscorwks.dll!__DangerousSwitchToThread() + 0x58 bytes	
     	mscorwks.dll!__SwitchToThread() + 0xd bytes	
     	mscorwks.dll!Thread::RareDisablePreemptiveGC() + 0x1df7ea bytes	
     	mscorwks.dll!GCHolder<1,1,0>::GCHolder<1,1,0>() + 0x22 bytes	
     	mscorwks.dll!UnwindFrameChain() + 0x22 bytes	
     	mscorwks.dll!CLRException::HandlerState::CleanupTry() + 0x190d43 bytes	
     	mscorwks.dll!ClassLoader::RunMain() + 0x83590 bytes	
     	mscorwks.dll!Assembly::ExecuteMainMethod() + 0xa4 bytes	
     	mscorwks.dll!SystemDomain::ExecuteMainMethod() + 0x39e bytes	
     	mscorwks.dll!ExecuteEXE() + 0x49 bytes	
     	mscorwks.dll!__CorExeMain@0() + 0x98 bytes	
     	mscoree.dll!__CorExeMain@0() + 0x32 bytes	
     	mscoree.dll!_ShellShim__CorExeMain@0() + 0x3a4e bytes	
     	mscoree.dll!__CorExeMain_Exported@0() + 0x8 bytes	
     	kernel32.dll!_BaseProcessStart@4() + 0x23 bytes	
    

    hope this is helpful for locate the problem

    Moreover, how can I dump the memory manually? because sometime, windows won't help to dump the memory even the problem occur...

     

    Monday, February 21, 2011 2:01 AM
  • Hi Cerberus,

    Looks, the first process is closing down before even the second process is started and hence memor problem is occuring. Why don't you wait for sometime, after starting another process like,

    System.Diagnostics.Process.Start("Main.exe", _uUser.UID);
    this.Visible = false;
    System.Threading.Thread.Sleep(500);
    Environment.Exit(0)
    

    Please mark this post as answer if it solved your problem. Happy Programming !!!
    Monday, February 21, 2011 2:11 PM
  • Hi Adavesh,

    I will try this tomorrow, and maybe need few weeks to get the result

    But you mean my "Main.exe" will lock or "scramble" the memory from Login.exe? or you mean my Main.exe is loading, and get all resource which make the Login.exe crash?

    Tuesday, February 22, 2011 1:47 AM
  • Hi Cerberus,

    Any update?


    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Thursday, February 24, 2011 9:40 AM
  • Hi eryang,

    Not yet, the program will be deployed within this week, it may need to wait 1 week for the result.

    Thursday, February 24, 2011 9:47 AM
  • Hi all,

    Seems I have no luck these days, that error still occur.

    Do I have any tools that can capture what happened? Or any suggestion that can let me avoid this error? thanks

    Friday, February 25, 2011 4:37 AM
  •  

    You can follow the article http://support.microsoft.com/default.aspx/kb/286350 to capture the dump file of the crashing process, e.g. use ADPlus command:

     

    adplus -crash -o d:\dumps -pn myapp

     

    (ADPlus is shipped with Debugging Tools For Windows which available at here), and then do some analyze using Windbg + SOS.


    Eric Yang [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Friday, February 25, 2011 6:03 AM
  • I'm sorry for the late reply, after a week of testing, we find out the problem is the crystal report control.

    GC cannot release the crystal report control before we init it again, and it make the memory address corrupt (or should I said changed?), so the windows marked that memory address cannot be read (cos using by another instance)

    Now we call crystal report control to dispose every time when we kill the Login.exe.

    At the end, thanks eric and Adavash for help.

    • Marked as answer by Cerberus Wang Tuesday, March 8, 2011 6:22 AM
    Tuesday, March 8, 2011 6:22 AM