C# で呼び出しているいくつかのエクスポートされた関数を含むC ++ファイルがあります。関数の1つはこれです:
char segexpc[MAX_SEG_LEN];
extern "C" QUERYSEGMENTATION_API char* fnsegc2Exported()
{
return segexpc2;
}
プログラムのどこかで、次のことも行っています。
if(cr1==1)
{
strcpy(segexpc, seg);
}
私のC#プログラムでは、次の方法で上記を呼び出しています。
[DllImport("QuerySegmentation.dll", EntryPoint = "fnsegcExported", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public static extern StringBuilder fnsegcExported();
this.stringbuildervar = fnsegcExported();
以前はエラーが発生しませんでしたが、ビジュアルスタジオでデバッグすると、突然このエラーが発生し始めました。
Windows has triggered a breakpoint in SampleAppGUI.exe.
This may be due to a corruption of the heap, which indicates a bug in SampleAppGUI.exe or any of the DLLs it has loaded.
This may also be due to the user pressing F12 while SampleAppGUI.exe has focus.
このエラーは、ウィンドウを表示する必要がある直前にのみ表示されます。F12 キーを押したことはなく、ここにブレークポイントも設定されていませんが、この時点でエラーが発生して壊れている理由がわかりません。 this.stringbuildervar = fnsegcExported();
続行を押すと、ウィンドウに正しい出力が表示されます。