OpenDocumentFile(NULL)

场景:急opendocumentfile(null)出错!该如何处理

急!opendocumentfile(null)出错!!
这个不会错吧,我把这里换成另外一个模板就没问题了
CTableDoc*   m_pDoc;
CDMSApp*   pApp   =   (CDMSApp*)AfxGetApp();
pApp-> tablename.Format( "%s ",tablename);
pApp-> m_pConn=m_pConn;
m_pDoc=(CTableDoc*)(pApp-> m_pTableDocTemplate-> OpenDocumentFile(NULL));
m_pDoc-> SetTitle(tablename);

下面是app   initinstance

BOOL   CDMSApp::InitInstance()
{

{ //   BLOCK:   doc   template   registration
//   Register   the   document   template.     Document   templates   serve
//   as   the   connection   between   documents,   frame   windows   and   views.
//   Attach   this   form   to   another   document   or   frame   window   by   changing
//   the   document   or   frame   class   in   the   constructor   below.
m_pTreeDocTemplate   =   new   CMultiDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CDMSDoc), //   document   class
RUNTIME_CLASS(CMDIChildWnd), //   frame   class
RUNTIME_CLASS(CTableSelectView)); //   view   class
AddDocTemplate(m_pTreeDocTemplate);
}


{ //   BLOCK:   doc   template   registration
//   Register   the   document   template.     Document   templates   serve
//   as   the   connection   between   documents,   frame   windows   and   views.
//   Attach   this   form   to   another   document   or   frame   window   by   changing
//   the   document   or   frame   class   in   the   constructor   below.
m_pTableDocTemplate   =   new   CMultiDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CTableDoc), //   document   class
RUNTIME_CLASS(CNewChildFrame), //   frame   class
RUNTIME_CLASS(CTableView)); //   view   class
AddDocTemplate(m_pTableDocTemplate);
}

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.

#ifdef   _AFXDLL
Enable3dControls(); //   Call   this   when   using   MFC   in   a   shared   DLL
#else
Enable3dControlsStatic(); //   Call   this   when   linking   to   MFC   statically
#endif

//   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 "));

LoadStdProfileSettings();     //   Load   standard   INI   file   options   (including   MRU)

//   Register   the   application 's   document   templates.     Document   templates
//     serve   as   the   connection   between   documents,   frame   windows   and   views.


CMultiDocTemplate*   pDocTemplate;
pDocTemplate   =   new   CMultiDocTemplate(
IDR_DMSTYPE,
RUNTIME_CLASS(CDMSDoc),
RUNTIME_CLASS(CChildFrame),   //   custom   MDI   child   frame
RUNTIME_CLASS(CDMSView));
AddDocTemplate(pDocTemplate);

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

//   Parse   command   line   for   standard   shell   commands,   DDE,   file   open
CCommandLineInfo   cmdInfo;
ParseCommandLine(cmdInfo);
cmdInfo.m_nShellCommand   =   CCommandLineInfo::FileNothing;
//   Dispatch   commands   specified   on   the   command   line
if   (!ProcessShellCommand(cmdInfo))
return   FALSE;

//   The   main   window   has   been   initialized,   so   show   and   update   it.
pMainFrame-> ShowWindow(m_nCmdShow);
pMainFrame-> UpdateWindow();

return   TRUE;
}

实在想不通有什么问题
我是多文档模式的啊
前面用m_pTreeDocTemplate   新建了一个文档,然后想在此基础上用m_pTableDocTemplate   创建一个,结果出错了,如果仍然建m_pTreeDocTemplate   就对的
请问为什么?谢谢

------解决方案--------------------
看看堆栈找到你自己的代码。