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。
爲什麼不直接P/Invoke CoCreateInstance()?或者使用類型庫和TlbImp.exe? – 2010-03-15 11:52:12
我想動態加載不同的一般,但有很多共同的COM庫。我放棄了並且使用了P/Invoke CreateObject,所以我總是綁定到庫我調用這個函數。 – markhor 2010-03-16 09:06:34