在完整的.NET框架解决方案中,我有以下代码:
public delegate int CreateObjectDelegate(
[In] ref Guid classID,
[In] ref Guid interfaceID,
[MarshalAs(UnmanagedType.Interface)] out object outObject);
...
var createObject = (NativeMethods.CreateObjectDelegate)
Marshal.GetDelegateForFunctionPointer(
NativeMethods.GetProcAddress(_modulePtr, "CreateObject"),
typeof (NativeMethods.CreateObjectDelegate));
object result;
Guid interfaceId = _guid;
Guid classID = _classId;
createObject(ref classID, ref interfaceId, out result);
其目的是在运行时创建所需的COM对象。是否可以使用任何.NET Compact框架?
注意,它没有marshal.getDelegateForFunctionPointer。