Managed Code Pls help me!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lars Grøtteland

    #1

    Managed Code Pls help me!

    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
    --


    - Lars


  • SunFire

    #2
    Re: Managed Code Pls help me!

    Hi
    [color=blue]
    > 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
    >[/color]

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

    Regards, Robert


    Comment

    • Stu Smith

      #3
      Re: Managed Code Pls help me!

      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.



      "Lars Grøtteland" <lars@nospam> wrote in message
      news:u%23vuM%23 k6DHA.2480@TK2M SFTNGP12.phx.gb l...[color=blue]
      > 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[/color]
      tried[color=blue]
      > to add it in my application I receive an error during compile:
      >
      > error C3828: 'MFC02::Form01' : placement arguments not allowed while[/color]
      creating[color=blue]
      > instances of managed classes
      >
      > The application is called MFC02 - the WindowsForm is called Form01. Here[/color]
      is[color=blue]
      > 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
      > --
      >
      >
      > - Lars
      >
      >[/color]


      Comment

      Working...