的.NET Compact COM互操作性

问题描述:

我有一个完整的.NET框架溶液以下代码:的.NET Compact COM互操作性

 

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 Framework?

请注意,它没有Marshal.GetDelegateForFunctionPointer。

+0

为什么不直接P/Invoke CoCreateInstance()?或者使用类型库和TlbImp.exe? – 2010-03-15 11:52:12

+0

我想动态加载不同的一般,但有很多共同的COM库。我放弃了并且使用了P/Invoke CreateObject,所以我总是绑定到库我调用这个函数。 – markhor 2010-03-16 09:06:34

对于无论(绝对愚蠢)的原因,CF不包括Marshal.GetDelegateForFunctionPointer。我一直在问这个团队多年。没有办法获取函数指针并在CF中调用它。