我有一个 C#.NET 2.0 CF 应用程序,它从具有以下签名的本机 DLL 导入函数:
__declspec( dllexport ) void DLL_Foo( int count, ... );
我的 C# 应用程序 P/Invokes 该功能如下:
public sealed class MyObject
{
public void Foo()
{
NativeMethods.DLL_Foo(2, __arglist("a","b"));
}
internal static class NativeMethods
{
[DllImport("My.dll")]
internal static extern void DLL_Foo(int count, __arglist);
}
}
但是,当我调用 时MyObject.Foo
,我得到一个System.MissingMethodException
.
我需要改变什么才能使这项工作?
谢谢,保罗
编辑:如果我将导入定义更改为:
internal static extern void DLL_Foo(int count, [MarshalAs(UnmanagedType.LPWStr)]string a, [MarshalAs(UnmanagedType.LPWStr)]string b);
然后,调用:
NativeMethods.DLL_Foo(2, "a", "b");
它没有问题,所以它与我的__arglist
用法有关。