2

C++/CLI ライブラリの関数を定義しました。

extern "C"
{
    INT_PTR __cdecl brl_graphics_Graphics(int Width, int Height, int Depth, int Hertz, int Flags);
}

そして、これはそれを呼び出す関数です。これは単なるラッパーです:

IntPtr BlitzMax::BlitzMax::Graphics(int Width, int Height, int Depth, int Hertz, int Flags)
{
    return IntPtr(brl_graphics_Graphics(Width, Height, Depth, Hertz, Flags));
}

C# アプリケーションから呼び出すと、AccessViolationException が発生します。何らかの理由で、逆アセンブリで cdecl 呼び出し規則が使用されていません。

push        dword ptr [ebp+10h] 
push        dword ptr [ebp+0Ch] 
push        dword ptr [ebp+8] 
mov         ecx,dword ptr [ebp-4] 
mov         edx,dword ptr [ebp-8] 
call        FFD595B8
4

1 に答える 1

0

あなたが何をしようとしているのか完全にはわかりませんが、このWebサイトはhttp://tom-shelton.net/index.php/2008/12/11/creating-a-managed-wrapper-に役立つ可能性があります。 for-a-lib-file/

ネイティブC++クラス(関数にすることもできます)を作成し、それらをC ++ / CLIラッパーでラップしてから、C#プログラムでラッパーを使用するためのステップバイステップガイドを提供します。

于 2012-10-26T13:29:11.543 に答える