Atl Problem: Passing variants array to .NET assembly expecting object from ATL dll
Posted on 2004-03-22
I have an atl component which is a leaf invoker component ,ie, it takes progids, input parameters, output parameters and one error string parameter it instanciates the component, and it uses dispatchdriver to invoke the function in question in a given component, the interface is given below.
interface ICgateway : IDispatch
[id(1), helpstring("method Invoke")] HRESULT Invoke([in] VARIANT * param1,[in] VARIANT* param2 ,[in,out]VARIANT* param3,[in,out] VARIANT* param4);
progid of a vb or vc com dll in param one, the input parameters to be passed to the component in question goes in param 2 as variant array, param 3 is for out values it is also variant array, and any error message is returned via param 4 this is BSTR type.
This component works fine as long as i give in progids of vb components which accept variants array as param2 and param3 parameters.
I have some .NET classes to be called but they accept object as parameter i have no idea how do i convert my variants array to objects so that i can pass them to .net component.
All components have same funcion signature and same type of parameter; that is,
somefunct( byval variant inparam, variant outparam, variant errstring) as long
only .NET components have object array as input and output parameter.
Ccan anyone help me out with this one? ...