1

vb6 COM dll から C# にメソッドを呼び出す方法を確認するためだけに、VB6 でテスト プロジェクトを作成しました。VB6 dllには、このように宣言されたメソッドがあります

Public Static Function Square(i As Integer) As Integer

    Square = i * i

End Function

C# からの呼び出しは以下のとおりです

    [DllImport("C:\\Documents and Settings\\user1\\My Documents\\Visual Studio 2010\\Projects\\Interop_Example\\WindowsFormsApplication1\\WindowsFormsApplication1\\bin\\Debug\\Project1.dll")]
    static extern int Square(int i);

    private void button1_Click(object sender, EventArgs e)
    {
        int i = Square(3);
    }

ただし、int i = Square(3) 行で entrypointnotfoundexception 例外がスローされ、インポートされた dll で Square というメソッドが見つかりません。なぜ不平を言っているのかわかりません。何か不足していますか? どんな提案でも大歓迎です。

ありがとう

4

0 に答える 0