C++断言异常,求高手~

C++断言错误,求高手~~~
我在写一个max的插件小程序来导出场景中的信息,由于要将场景信息导出到一个txt文件。所以用了BeginWriting()、Write()和EndWriting()函数,编译通过,但是在启动max之后导出信息时出现断言错误。给出的错误信息显示在BeginWriting()函数里的断言错误。下边是部分代码:求高手帮助!!!!
int maxProject5::DoExport(const TCHAR *name,ExpInterface *ei,Interface *i, BOOL suppressPrompts, DWORD options)
{

if (BeginWriting(name))
{

INode* pRootNode = i->GetRootNode();

//Export tree.
Export(pRootNode,0);

EndWriting();

return TRUE; // We have successfully exported to our file!
}

// If we are here, something in the export failed.
return FALSE;
}
BOOL maxProject5::BeginWriting(const char *pPath)
{
// Check we are not currently writing
DbgAssert(m_pFile == NULL);//断言

errno_t lErr = fopen_s(&m_pFile, pPath, "w");
return lErr == 0;
}

void maxProject5::EndWriting()
{
DbgAssert(m_pFile != NULL);

fclose(m_pFile);
m_pFile = NULL;
}

void maxProject5::Write(int indent, const char* pMsg, ...)
{
DbgAssert(m_pFile != NULL);

// first, write in the indent
for (int i = 0; i < indent; i++)
fprintf_s(m_pFile, "\t");//C++库函数

// Write the message, passing in our variable
// parameters to a function that wraps printf
va_list vargs;
va_start(vargs, pMsg);//fprintf()的封装
vfprintf_s(m_pFile, pMsg, vargs);
va_end(vargs);//http://www.cnblogs.com/leaven/archive/2010/06/29/1767374.html

// Finish the line
fprintf_s(m_pFile, "\n");
}
m_pFile是在类中定义的私有变量。其他代码没有涉及,只有贴出部分用到,各位多帮忙啊~

------解决方案--------------------
如果m_pFile是你自己定义的变量,那么构造函数中有没有初始化为NULL?

------解决方案--------------------
m_pFile此时不是NULL,至于为啥不是NULL,单步调试。从对象创建开始,跟到BeginWriting被调用,看看是什么导致m_pFile不是NULL
------解决方案--------------------
我看把这个断言注销也不影响你代码
------解决方案--------------------
用_T("w")试试
------解决方案--------------------
单步调试,断言已经说了
Expression: ("Incorrect format specifier",0)
接下来就看到时你代码里是怎么回事了。