2

C で記述された DLL ファイルがあります。C# コードで C DLL を使用しようとしています。C プログラム メソッド return int** . cのint**とc#のint[][]は同じですか?

C プログラムから値を返すときにエラーが発生します。

c法

__declspec(dllexport) int someMethod
    (
        size_t *foo, 
        int **bar
    ) 
    { 
        *foo = 10; 
        **bar = 10; 
    }

私のC#コード

[DllImport(@"my.dll", CallingConvention = CallingConvention.Cdecl, SetLastError = true, BestFitMapping = true, EntryPoint = "someMethod")]
    public unsafe static extern int someMethod
    (
        out Int16 foo, 
        [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(JaggedArrayMarshaler))] 
        out int[][] bar
    );
4

2 に答える 2