假设你有以下C ++代码:
extern "C" {
void testA(int a, float b) {
}
static void testB(int a, float b){
}
}
我想在我的C#项目中使用它来访问它 DllImport
:
class PlatformInvokeTest
{
[DllImport("test.so")]
public static extern void testA(int a, float b);
[DllImport("test.so")]
internal static extern void testB(int a, float b);
public static void Main()
{
testA(0, 1.0f);
testB(0, 1.0f);
}
}
这非常适合 testA
但是 testB
无法抛出EntryPointNotFoundException。
我可以访问吗? testB
从我的C#代码?怎么样?