CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2007
    Location
    Bangalore,India
    Posts
    164

    Smile in dialog dll because of App class instance application being crashed

    I have dll where I am creating a dialog whihc is shown from the mfc client application. I loading this dll as an extension dll, then by implementing Do.Modal() function I am showing the dialog which has menus, toolbars,black model visualization screen. When trying to display this screen, it's crashing as debug ASSERT failed, at appcore.cpp
    ASSERT(AfeGetThread()==NULL)

    My App class is like this in the header file I have the App constructor and in .cpp file I have the construcor and also one instance of ViewApp as below
    //MyViewApp.h
    Code:
    //Inside the class definition
    MyViewApp(); //constructor dclaration
    
    //outside the class definition
    extern MyViewApp theApp;
    //MyViewApp.cpp
    Code:
    MyViewApp::MyViewApp()
    {
    }
    
    MyViewApp theApp;
    It's crashing with this code (ASSERT failure in appcore.cpp), and when I am removing this constructor declaration and definition and also removing the one instantiation, then it's not crashing but coming out of the application, My Dialog GUI is not launching.

    Please help me whats going wrong in this. Thanks a lot for help in advance.

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: in dialog dll because of App class instance application being crashed

    Where is your MyViewApp::InitInstance implementation?
    Victor Nijegorodov

  3. #3
    Join Date
    Sep 2007
    Location
    Bangalore,India
    Posts
    164

    Re: in dialog dll because of App class instance application being crashed

    It is there in the MyViewApp.cpp file after the constructor.
    Code:
    // DlgsView.cpp : Defines the class behaviors for the application.
    //
    
    #include "stdafx.h"
    #include "DlgsView.h"
    #include "DlgsViewDlg.h"
    
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #endif
    
    
    // CDlgsViewApp
    
    BEGIN_MESSAGE_MAP(CDlgsViewApp, CWinApp)
    	ON_COMMAND(ID_HELP, &CWinApp::OnHelp)
    END_MESSAGE_MAP()
    
    
    // CDlgsViewApp construction
    
    CDlgsViewApp::CDlgsViewApp()
    {
    	// TODO: add construction code here,
    	// Place all significant initialization in InitInstance
    }
    
    
    // The one and only CDlgsViewApp object
    
    CDlgsViewApp theApp;
    
    
    // CDlgsViewApp initialization
    
    BOOL CDlgsViewApp::InitInstance()
    {
    	// InitCommonControlsEx() is required on Windows XP if an application
    	// manifest specifies use of ComCtl32.dll version 6 or later to enable
    	// visual styles.  Otherwise, any window creation will fail.
    	INITCOMMONCONTROLSEX InitCtrls;
    	InitCtrls.dwSize = sizeof(InitCtrls);
    	// Set this to include all the common control classes you want to use
    	// in your application.
    	InitCtrls.dwICC = ICC_WIN95_CLASSES;
    	InitCommonControlsEx(&InitCtrls);
    
    	CWinApp::InitInstance();
    
    	AfxEnableControlContainer();
    
    	// Standard initialization
    	// If you are not using these features and wish to reduce the size
    	// of your final executable, you should remove from the following
    	// the specific initialization routines you do not need
    	// Change the registry key under which our settings are stored
    	// TODO: You should modify this string to be something appropriate
    	// such as the name of your company or organization
    	SetRegistryKey(_T("Local AppWizard-Generated Applications"));
    
    	CDlgsViewDlg dlg(L"", NULL);
    	m_pMainWnd = &dlg;
    	INT_PTR nResponse = dlg.DoModal();
    	if (nResponse == IDOK)
    	{
    		// TODO: Place code here to handle when the dialog is
    		//  dismissed with OK
    	}
    	else if (nResponse == IDCANCEL)
    	{
    		// TODO: Place code here to handle when the dialog is
    		//  dismissed with Cancel
    	}
    
    	// Since the dialog has been closed, return FALSE so that we exit the
    	//  application, rather than start the application's message pump.
    	return FALSE;
    }

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: in dialog dll because of App class instance application being crashed

    Quote Originally Posted by sujan.dasmahapatra View Post
    I have dll where I am creating a dialog whihc is shown from the mfc client application. I loading this dll as an extension dll, then by implementing Do.Modal() function I am showing the dialog which has menus, toolbars,black model visualization screen. When trying to display this screen, it's crashing as debug ASSERT failed, at appcore.cpp
    ASSERT(AfeGetThread()==NULL)

    My App class is like this in the header file I have the App constructor and in .cpp file I have the construcor and also one instance of ViewApp as below
    //MyViewApp.h
    Code:
    //Inside the class definition
    MyViewApp(); //constructor dclaration
    Well, please, don't invent non-existing MFC constructions!
    There is no such a AfeGetThread function, there is AfxGetThread
    And there is no Do.Modal() "function", you probably meant DoModal()?

    Quote Originally Posted by sujan.dasmahapatra View Post
    //MyViewApp.h
    Code:
    //Inside the class definition
    MyViewApp(); //constructor dclaration
    
    //outside the class definition
    extern MyViewApp theApp;
    What class exactly do you use in your project: MyViewApp or CDlgsViewApp?

    Quote Originally Posted by sujan.dasmahapatra View Post
    It is there in the MyViewApp.cpp file after the constructor.
    Code:
    // DlgsView.cpp : Defines the class behaviors for the application.
    //
    ...
    // CDlgsViewApp
    
    CDlgsViewApp::CDlgsViewApp()
    {
    	// TODO: add construction code here,
    	// Place all significant initialization in InitInstance
    }
    
    // The one and only CDlgsViewApp object
    
    CDlgsViewApp theApp;
    ...
    }
    How many global App objects did you defined in your exe? In dll?
    Victor Nijegorodov

  5. #5
    Join Date
    Sep 2007
    Location
    Bangalore,India
    Posts
    164

    Re: in dialog dll because of App class instance application being crashed

    CDlgsViewApp

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: in dialog dll because of App class instance application being crashed

    Quote Originally Posted by sujan.dasmahapatra View Post
    CDlgsViewApp
    Well, why did you ignore my second question?
    Well, again:
    Quote Originally Posted by VictorN View Post
    ...
    What class exactly do you use in your project: MyViewApp or CDlgsViewApp?

    How many global App objects did you defined in your exe? In dll?
    And now the third question: is your dll an extension or a regular one?
    Victor Nijegorodov

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured