Sign in to follow this  
guangwang1983

Weird Problem

Recommended Posts

Hi guys, I have really weird problem. I have an application written in VC++. It works fine if I do "start debugging" under both debug or release. But none of the build works if I double click the executable in windows explorer. It jsut crashes straight away with the dialog saying "application has encountered a problem and needs to close." Does anyone know what might be causing it? Any help will be appreciated. Thanks

Share this post


Link to post
Share on other sites
Visual Studio has different ways of initialising memory when you run through the debugger.

You could try putting a Sleep(30000) in your main entry function, run your application and then attach the debugger to it (in Debug->Processes in vc2003, Debug->Attach to Process in vc2005, not sure about 2008 - you will have 30 seconds - change the 30000 value if your not quick enough ;)

Your program should then hopefully crash in the same place and you can debug as normal to find the cause of the problem.

Share this post


Link to post
Share on other sites
Quote:
Original post by _moagstar_
Visual Studio has different ways of initialising memory when you run through the debugger.

You could try putting a Sleep(30000) in your main entry function, run your application and then attach the debugger to it (in Debug->Processes in vc2003, Debug->Attach to Process in vc2005, not sure about 2008 - you will have 30 seconds - change the 30000 value if your not quick enough ;)

Your program should then hopefully crash in the same place and you can debug as normal to find the cause of the problem.


Thanks a lot for that. I will give it a try!

Share this post


Link to post
Share on other sites
Thanks for the help guys. I just found out what is wrong with it, but it actually puzzles a lot more. Bascially, I have a class saving all the parameter for the application. And it appears that removing any one variable in the class will fix the problem. Surely there isnt a limit on how many variables you can have in one class. Does that mean my problem is somewhere else in the code?

Share this post


Link to post
Share on other sites
Quote:
Original post by guangwang1983
I have a class saving all the parameter for the application.


How is it saving the parameters?

Quote:
Original post by guangwang1983
Surely there isnt a limit on how many variables you can have in one class.


I'm sure every compiler technically has some memory limit that it will hit at some point - but you are never going to reach it, don't use this as an excuse to create 'blob' like classes though.

Quote:
Original post by guangwang1983
Does that mean my problem is somewhere else in the code?


Not necessarily, the fact that it's this piece of code that's crashing and that removing a variable stops it from occuring would suggest it is something in your saving that's causing the problem.

What exactly is the crash you are getting and what is it that you are doing to save the variables, do you have any code we could take a look at?

Share this post


Link to post
Share on other sites
I am sorry for not providing enough details

Basically, my class class contains very simple int, CString and double. It saves/loads them from the registry when the system start/close. It crashes when it is loading stuff from the registry, so no other code was executed before that.

It crashes on this line below.

CString m_strCompanyName = pApp->m_pszRegistryKey; where pApp is the pointer to my main CWinApp.

Can anyone shed any light on this?

Thanks

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this