Click here to Skip to main content
15,868,164 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is the function i am having problem

C++
void CDesktopApp::OnSillyPaste()
{
	
	CMainFrame* pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd);
	// create a new MDI child window
	pFrame->CreateNewChild(
		RUNTIME_CLASS(CPrintingFrame), IDR_DesktopTYPE, m_hMDIMenu, m_hMDIAccel); // application fail around this line during runtime of release version. but debug version perform normal. 
//definition of CPrintingFrame 
/*
class CPrintingFrame: public CMDIChildWndEx
{};
*/

//IDR_DesktopTYPE is a macro with value 130
//hMDIMenu is HMENU type;
//m_hMDIAccel is HACCEL type;
}

//another function that behave well

void CDesktopApp::OnCustomerFileRequest()
{
	CMainFrame* pFrame = STATIC_DOWNCAST(CMainFrame, m_pMainWnd);
	// create a new MDI child window
	pFrame->CreateNewChild(
		RUNTIME_CLASS(CCustomerReportFrm), IDR_DesktopTYPE, m_hMDIMenu, m_hMDIAccel);
}


as I stated in the code that it fails there (I tested). The error is related with heap corruption. What can go wrong?

If ask for more code it would be hard for me to judge about what else to put..
Posted
Updated 25-Dec-12 16:13pm
v2

Here is an in-depth article on Debug vs. Release - Surviving the Release Version[^]
 
Share this answer
 
Comments
Mohibur Rashid 26-Dec-12 4:06am    
good tips
I had similar problem of something works fine in Debug and Crash in Release version. Atlast i found some integer variables are automatically initizlized to 0 in Debug mode. The same variables carry some junk value in Release mode. After initilizing proper values, it went fine for me.

please check your variables m_hMDIMenu, m_hMDIAccel holds the same expected values in both debug and release version. may be a reason !
 
Share this answer
 
Comments
[no name] 26-Dec-12 0:21am    
Thanks for your comment, Interestingly, it got fixed for no reason(or at least some reason that I can't explain). I added some code to find out exactly what location it is making the trouble. But instead of showing the error again, it got fixed. I removed those test code too, but still its working. I am disappointed. Cause I wanted to see the error

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900