Compilation Error :placement arguments not allowed?

  • Thread starter Thread starter Raed Sawalha
  • Start date Start date
R

Raed Sawalha

i have the following scenario

I've created MFC Application using Visual Studio 2003, then change the
project settings
to use Managed Extensions as follows:

1. Configuration Properties->General->use Managed Extension : Yes
2. C/C++->General->Debug Information Format : Program Database (/Zi)
3. C/C++->Code Generation->Enable Minimal Build : No
4. C/C++->Basic Run-Time Check : Default


then in the CMyClassDlg.cpp did the following:

#using <mscorlib.dll>
#using <System.dll>
using namespace System;
#using <System.Xml.dll>
#using <System.Data.dll>


and in the OnInitDialog() did :

XmlDocument *xmlDoc = new XmlDocument();
//Just this to try

and compile this error message appeared:

(105): error C3828: 'System::Xml::XmlDocument': placement arguments not
allowed while creating instances of managed classes

I dont know why this error generated ,though I did the same thing in my
ISAPI Filter DLL project and used XmlDocument
and SqlClient effectively.


why this happening in MFC application .
Any Idea? Regards.
 
Raed Sawalha said:
and in the OnInitDialog() did :

XmlDocument *xmlDoc = new XmlDocument();
//Just this to try

and compile this error message appeared:

(105): error C3828: 'System::Xml::XmlDocument': placement arguments not
allowed while creating instances of managed classes
This might due to some magic MFC applies to trace memory leaks.
In debug builds MFC used to redefine new to call a placement
version of the operator ( e.g.: new (__FILE__,__LINE__) XmlDocument ).

Placement syntax is not supported for managed objects.

Can you try to build in release mode or #undef new after the MFC
header #includes?
I'm not sure there is a good way to use MFC memory checks along
with managed functionality. Maybe you want to write a template
function to create GC objects.

-hg
 
Back
Top