|
-
October 30th, 2011, 08:53 PM
#1
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
-
October 30th, 2011, 09:54 PM
#2
Re: CFile::Dump causes "Unable to dump object in static release builds" error
 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
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
-
October 31st, 2011, 05:45 PM
#3
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.
-
November 1st, 2011, 02:06 AM
#4
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);
-
November 1st, 2011, 07:07 PM
#5
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.
-
November 2nd, 2011, 05:24 AM
#6
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.
-
November 2nd, 2011, 07:09 PM
#7
Re: CFile::Dump causes "Unable to dump object in static release builds" error
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|