Implement IDispatch with using ICustomQueryInterface. Set property - not working
See the question and my original answer on StackOverflowYou should change the Invoke definition like this:
void Invoke(
int dispId,
ref Guid riid,
int lcid,
System.Runtime.InteropServices.ComTypes.INVOKEKIND wFlags,
ref System.Runtime.InteropServices.ComTypes.DISPPARAMS pDispParams,
[Out, MarshalAs(UnmanagedType.LPArray)] object[] result,
IntPtr pExcepInfo,
IntPtr puArgErr);
and use it like this:
public void Invoke(int dispId, ref Guid riid, int lcid, System.Runtime.InteropServices.ComTypes.INVOKEKIND wFlags, ref System.Runtime.InteropServices.ComTypes.DISPPARAMS pDispParams, out object result, IntPtr pExcepInfo, IntPtr puArgErr)
{
string name;
dispIdNameMap.TryGetValue(dispId, out name);
if (result != null)
{
result[0] = name;
}
}