Managed Code Pls help me!

  • Thread starter Thread starter Lars Grøtteland
  • Start date Start date
L

Lars Grøtteland

Hello!

Could anyone help me please.
I tried the following - I created an application in .NET 2003. The project
is a MFC Application a CDialog. I ran the application fine. I changed the
properties for the app - so I should use Managed Code (Use Managed
Extensions = YES). It still ran fine. I should now be able to add new
things like Windows Forms. Am I right?
You see I tried to add a Windows Form(:NET) item in my app, but when I tried
to add it in my application I receive an error during compile:

error C3828: 'MFC02::Form01': placement arguments not allowed while creating
instances of managed classes

The application is called MFC02 - the WindowsForm is called Form01. Here is
my code to get this error
MFC02::Form01* myform = new MFC02::Form01();

What am I missing?
Is it so that I can't use unmanaged code togheter with managed code? Is my
code unmanaged when I selected that I should use Use Managed Extensions =
YES

Could anyone please help me
Thanks
 
Hi
MFC02::Form01* myform = new MFC02::Form01();

What am I missing?
Is it so that I can't use unmanaged code togheter with managed code? Is my
code unmanaged when I selected that I should use Use Managed Extensions =
YES

have you added apriopriate references to your project?
did you add reference to mscorlib.dll?

Regards, Robert
 
The problem is that if you do a debug build of MFC apps, in one of the
windows header files, 'new' is #defined to be something else (DEBUG_NEW
actually, which is itself a macro) (try right-clicking on the new and
selecting go to definition).

You could try something like:

#ifdef new
#undef new
#endif

ManagedClass *pManagedObject = new ManagedClass();

#ifdef _DEBUG
#define new DEBUG_NEW
#endif


Macros are evil, basically.
 
Back
Top