2010-03-15 109 views
0

我有一個完整的.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

回答

1

對於無論(絕對愚蠢)的原因,CF不包括Marshal.GetDelegateForFunctionPointer。我一直在問這個團隊多年。沒有辦法獲取函數指針並在CF中調用它。