D
Dmitry Medvedev
Hello,
I need to write C# class, that would implement IDispatch interface to be
used in ActiveScript.
I can't use IReflect interface here due to design issues, I need to handle
GetIDsOfNames and Invoke manually.
I've tried the following code:
[Guid("00020400-0000-0000-C000-000000000046")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDispatch
{
[PreserveSig]
int GetTypeInfoCount(out int Count);
[PreserveSig]
int GetTypeInfo( [MarshalAs(UnmanagedType.U4)] int iTInfo,
[MarshalAs(UnmanagedType.U4)] int lcid, out UCOMITypeInfo typeInfo);
[PreserveSig]
int GetIDsOfNames( ref Guid riid,
[MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPWStr)]
string[] rgsNames,
int cNames, int lcid, [MarshalAs(UnmanagedType.LPArray)] int[]
rgDispId);
[PreserveSig]
int Invoke(int dispIdMember, ref Guid riid, uint lcid, ushort wFlags,
ref DISPPARAMS pDispParams, out object pVarResult, ref EXCEPINFO
pExcepInfo, IntPtr[] pArgErr);
[ClassInterface(ClassInterfaceType.None)]
public class ActiveScriptWrapper : IDispatch
.....
and
Marshal.GetIDispatchForObject(new ActiveScriptWrapper()) results in
exception.
Looks like it's not possible to implement IUnknown and IDispatch interfaces
in .NET classes.
Could anyone help me with this task?
Regards,
Dmitry
I need to write C# class, that would implement IDispatch interface to be
used in ActiveScript.
I can't use IReflect interface here due to design issues, I need to handle
GetIDsOfNames and Invoke manually.
I've tried the following code:
[Guid("00020400-0000-0000-C000-000000000046")]
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IDispatch
{
[PreserveSig]
int GetTypeInfoCount(out int Count);
[PreserveSig]
int GetTypeInfo( [MarshalAs(UnmanagedType.U4)] int iTInfo,
[MarshalAs(UnmanagedType.U4)] int lcid, out UCOMITypeInfo typeInfo);
[PreserveSig]
int GetIDsOfNames( ref Guid riid,
[MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPWStr)]
string[] rgsNames,
int cNames, int lcid, [MarshalAs(UnmanagedType.LPArray)] int[]
rgDispId);
[PreserveSig]
int Invoke(int dispIdMember, ref Guid riid, uint lcid, ushort wFlags,
ref DISPPARAMS pDispParams, out object pVarResult, ref EXCEPINFO
pExcepInfo, IntPtr[] pArgErr);
[ClassInterface(ClassInterfaceType.None)]
public class ActiveScriptWrapper : IDispatch
.....
and
Marshal.GetIDispatchForObject(new ActiveScriptWrapper()) results in
exception.
Looks like it's not possible to implement IUnknown and IDispatch interfaces
in .NET classes.
Could anyone help me with this task?
Regards,
Dmitry