CFile::Dump causes "Unable to dump object in static release builds" error
Hi,
In VC++ 2008, when I define a CFile object m_File and then want to dump its contents, as follows:
dc << m_File;
where dc is the dump context object.
I will get the following error in the output window:
"Unable to dump object in static release builds".
How to solve the problem?
Thanks
Re: CFile::Dump causes "Unable to dump object in static release builds" error
Quote:
Originally Posted by
AlanCCC
Hi,
In VC++ 2008, when I define a CFile object m_File and then want to dump its contents, as follows:
dc << m_File;
where dc is the dump context object.
I will get the following error in the output window:
"Unable to dump object in static release builds".
How to solve the problem?
Thanks
http://msdn.microsoft.com/en-us/libr...=vs.80%29.aspx
Quote:
Dump calls make sense only in the Debug version of the Microsoft Foundation Class Library. You should bracket calls, function declarations, and function implementations with #ifdef _DEBUG/#endif statements for conditional compilation.
Regards,
Paul McKenzie
Re: CFile::Dump causes "Unable to dump object in static release builds" error
I just use #ifdef _DEBUG/#endif to bracket call to dc << m_File; and I am just in debug status when seeing that error message.
Re: CFile::Dump causes "Unable to dump object in static release builds" error
If set a breakpoint then step into, you can notice the following in one CDumpContext::operator<<
Code:
#ifdef _AFXDLL
pOb->Dump(*this);
#else
*this << _T("Unable to dump object in static release builds");
#endif
That means in your project _AFXDLL is not defined, most possible because you are using static libraries of MFC.
To get rid of that, change "Use MFC in a Static Library" to "Use MFC in a Shared DLL", in your project properties.
Alternatively, in this particular case, you can call CFile::Dump instead of using << operator.
Code:
// afxDump << file; // <-- replace this.
file.Dump(afxDump);
Re: CFile::Dump causes "Unable to dump object in static release builds" error
Thank you for your explanation.
Yes, my project is using MFC as static library. But I am very confused. Why a static MFC library will prevent me from dumping object, while I am still in DEBUG mode? This is not in logic.
Re: CFile::Dump causes "Unable to dump object in static release builds" error
I don't know, may be an internal MFC-framework reason.
Anyway, just choose one of the two solutions I pointed above and avoid such "existential" headaches. ;)
Re: CFile::Dump causes "Unable to dump object in static release builds" error