Hi all,
In my MDI when i try to execute i am getting an assertion error pointing to wincore.cpp line 311.

BOOL CWnd::Attach(HWND hWndNew)
	ASSERT(m_hWnd == NULL);     // only attach once, detach on destroy
	ASSERT(FromHandlePermanent(hWndNew) == NULL);
		// must not already be in permanent map

here is the snippet of the mfc inbuilt code where the assertion error occurs.
The error occurs when the main window is tried to display(attach).

This is the part of the code in the application where the assertion error occurs.

if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;

Could you please help me to weed out the possible cause of this assertion error

The error is occurring because CWnd::Attach() is requiring an internal window-handle object to be NULL ... that is, presumably, not already initialized in some other way.

I suspect your problem may be that you're calling pMainFrame->LoadFrame() more than once (maybe inside a loop?), or possibly making some other call that initializes CWnd's internal window-handle object.

If you still can't figure it out, please post a bit more of your own code (especially preceding the 2 lines you've provided so far). Thanks!

SetDialogBkColor();        // Set dialog background color to gray
	LoadStdProfileSettings();  // Load standard INI file options (including MRU)
    m_bCtl3dRegistered = TRUE;

	// create main MDI Frame window
	CMainFrame* pMainFrame = new CMainFrame;
	if (!pMainFrame->LoadFrame(IDR_MAINFRAME))
		return FALSE;

This is the part of the code where the exception occured

	// Instantiate GPPrint.exe
 	HWND hPrint = ::FindWindow("PPrint", NULL);

This is the part of the constructor of CMainframe.
Also i tried by commenting out the code present in the constructor bust still got the same error. am using vc++ 6.0

Found this thread on google (search: "CMainFrame LoadFrame"): http://www.codeguru.com/forum/archive/index.php/t-397306.html -- comments towards the bottom might be especially helpful: make sure you're correctly calling PreCreateWindow, and/or CMainFrame's Create() method may be preferable to calling LoadFrame() inherited from CFrameWnd.