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.