如何在c++中访问cli类

How to access a cli class in c++?

本文关键字:访问 cli c++      更新时间:2023-10-16

我需要在纯C++代码中创建一个cli类的新对象。

我是cli的新手,请帮助

我的cli类:

using namespace System;
using namespace System::Windows::Forms;
using namespace CrystalDecisions::Shared;
using namespace CrystalDecisions::CrystalReports::Engine;
using namespace CrystalDecisions::Windows::Forms;
namespace  CrystalRapport {
    // This is the main form that will hold the viewer control.  
    ref class ViewForm : public System::Windows::Forms::Form
    {
    private:
        //Declare the Viewer Control, Report Document, and other
        //objects needed to set the connection information.
    public:
        ViewForm()..
        void InitForm()..
        //This function initializes the form and adds the viewer to the form.
        void ViewForm_Load(System::Object^ sender, System::EventArgs^ e)..
    };
}

如果要创建,则需要使用gcnew。NET对象。

ref class Student
{
    ...
};
...
Student^ student = gcnew Student();
student->SelectSubject("Math", 97);

参考编号:http://www.codeproject.com/Articles/17787/C-CLI-in-Action-Instantiating-CLI-classes

我找到了一个例子。使用NET程序集在本机C++应用程序中的应用

http://msdn.microsoft.com/en-us/vstudio/bb892742.aspx

如果您创建了一个C#Crystal Reports项目,您可以使用此示例。(有一些变化)