CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2010
    Posts
    54

    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

  2. #2
    Join Date
    Apr 1999
    Posts
    27,449

    Re: CFile::Dump causes "Unable to dump object in static release builds" error

    Quote Originally Posted by AlanCCC View Post
    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

  3. #3
    Join Date
    Nov 2010
    Posts
    54

    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.

  4. #4
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    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);
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  5. #5
    Join Date
    Nov 2010
    Posts
    54

    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.

  6. #6
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    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.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

  7. #7
    Join Date
    Nov 2010
    Posts
    54

    Re: CFile::Dump causes "Unable to dump object in static release builds" error

    Thank you so much!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured