画像やファイルが無くなっていますがご了承下さい

なでしこでプラグインを作る時にC#を使いたかったので、本格的にdllを作る前に、C++/CLIからMessageBoxを表示する程度のC#のdllを呼び出してみました。

C#のdllコード

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Text;
namespace ClassLibrary1{
    public class Class1
    {
        public static void Method1()
        {
            MessageBox.Show("method1");
        }
    }
}

C++フォームアプリケーション

C#で作ったdllの参照とかフォームの構成とか画像が消えちゃったので適当に想像してください。 用はC++のアプリケーションでC#のdllを参照します。

ボタンクリック時のコード

    private: System::Void button1_Click(System::Object^  sender¸ System::EventArgs^  e) {
         try{
            ClassLibrary1::Class1::Method1();
         }catch(Exception^ e){
            System::Windows::Forms::MessageBox::Show(e->Message);
         }
     }

で動かしてみるときちんと動かせました。