call new instance of c# class in vc++ RRS feed

  • Question

  • I have a vc++ project to which I have referenced a c# project. I now want to call a new instance of a class from my c# project.

    vc++ project

    void CKingimageView::Onany()
    //call new instance of ClassLibrary::Class1

    c# project

    namespace ClassLibrary1
    public class Class1
    public void hello()

    using the following 
    Classlibrary1::Class1 class1 = new ClassLibrary1::Class1();

    gives error

    Error    1    error C3828: 'ClassLibrary1::Class1': placement arguments not allowed while creating instances of managed classes    c:\Users\kunal\Documents\Visual Studio 2008\Projects\TA_Sample_Win2007_Net\Winsample2007\kingimageView.cpp    228    kingimage

    Could you please tell me the correct syntax of create a new instance of class1


    Thursday, September 11, 2008 8:40 PM


  • Classlibrary1::Class1^ class1 = gcnew ClassLibrary1::Class1();
    Thursday, September 11, 2008 9:37 PM

All replies