开发者

.NET Compact COM interoperability

开发者 https://www.devze.com 2022-12-23 02:33 出处:网络
I have the following code in a full .NET framework solution: public delegate int CreateObjectDelegate(

I have the following code in a full .NET framework solution:


public delegate int CreateObjectDelegate(
            [In] ref Guid classID,
            [In] re开发者_运维技巧f 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);

The purpose is to create the needed COM object at runtime. Is it possible with any .NET compact framework?

Note that it doesn't have Marshal.GetDelegateForFunctionPointer.


For whatever (absolutely stupid) reason, the CF doesn't include Marshal.GetDelegateForFunctionPointer. I've been asking the team for it for years. There's simply no way to take a function pointer and call it in the CF.

0

精彩评论

暂无评论...
验证码 换一张
取 消