COleDispatchDriver.InvokeHelper PROBLEM
-
Hi ! my problem is as follows: I have a COM module ( COM_A) written in C++ which receives several [IN] parameters and returns [OUT] parameters. One of the input parameters is defined as [in] VARIANT vArrIn. One of the output params is defined as [out] VARIANT *dArrOut. There is no problem when I make the call directly to the respective method ! The problem arises when I try to call COM_A by means of a second COM module (COM_B), which makes use of the COleDdispatchDriver class. When I call COM_A from within COM_B by invoking InvokeHelper, the call fails and the return code says something like : "stub received bad data ...". I found out that : 1) If there is a normal [in]int parameter AFTER the [in]VARIANT vArrIn, , the call fails. 2) if I invert the order of the params [in]int iVal, [in]VARIANT vArrIn, the calls succeeds. 2)Anyway, it never succeeds when there is an [out] VARIANT *dArrOut after the [in]VARIANT vArrIn parameter. Why is this happening ? Is it possible to do it this way ? Can someone please shed a light on this. I tried out many different possibilities, including trying to define the [in]VARIANT as a pointer and to define the [OUT] VARIANT* array as [in,out], it all wouldn't help. Please help , because I need to find a solution. Thanks in advance, Rubi
-
Hi ! my problem is as follows: I have a COM module ( COM_A) written in C++ which receives several [IN] parameters and returns [OUT] parameters. One of the input parameters is defined as [in] VARIANT vArrIn. One of the output params is defined as [out] VARIANT *dArrOut. There is no problem when I make the call directly to the respective method ! The problem arises when I try to call COM_A by means of a second COM module (COM_B), which makes use of the COleDdispatchDriver class. When I call COM_A from within COM_B by invoking InvokeHelper, the call fails and the return code says something like : "stub received bad data ...". I found out that : 1) If there is a normal [in]int parameter AFTER the [in]VARIANT vArrIn, , the call fails. 2) if I invert the order of the params [in]int iVal, [in]VARIANT vArrIn, the calls succeeds. 2)Anyway, it never succeeds when there is an [out] VARIANT *dArrOut after the [in]VARIANT vArrIn parameter. Why is this happening ? Is it possible to do it this way ? Can someone please shed a light on this. I tried out many different possibilities, including trying to define the [in]VARIANT as a pointer and to define the [OUT] VARIANT* array as [in,out], it all wouldn't help. Please help , because I need to find a solution. Thanks in advance, Rubi
Hello Rubi, Sounds like your problem may be related to marshaling. However, if possible, it would be best if you could send me a scaled down and modified version of your COM server and client code that can re-create the problem. Please send to : bio_lim_2004@yahoo.com Best Regards, Bio.
-
Hi ! my problem is as follows: I have a COM module ( COM_A) written in C++ which receives several [IN] parameters and returns [OUT] parameters. One of the input parameters is defined as [in] VARIANT vArrIn. One of the output params is defined as [out] VARIANT *dArrOut. There is no problem when I make the call directly to the respective method ! The problem arises when I try to call COM_A by means of a second COM module (COM_B), which makes use of the COleDdispatchDriver class. When I call COM_A from within COM_B by invoking InvokeHelper, the call fails and the return code says something like : "stub received bad data ...". I found out that : 1) If there is a normal [in]int parameter AFTER the [in]VARIANT vArrIn, , the call fails. 2) if I invert the order of the params [in]int iVal, [in]VARIANT vArrIn, the calls succeeds. 2)Anyway, it never succeeds when there is an [out] VARIANT *dArrOut after the [in]VARIANT vArrIn parameter. Why is this happening ? Is it possible to do it this way ? Can someone please shed a light on this. I tried out many different possibilities, including trying to define the [in]VARIANT as a pointer and to define the [OUT] VARIANT* array as [in,out], it all wouldn't help. Please help , because I need to find a solution. Thanks in advance, Rubi
Take a look into MSDN's "Passing Parameters" topic (or search for these words). From there: typedef struct FARSTRUCT tagDISPPARAMS{ VARIANTARG FAR* rgvarg;// Array of arguments. DISPID FAR* rgdispidNamedArgs; // Dispatch IDs of named arguments. unsigned int cArgs;// Number of arguments. unsigned int cNamedArgs; // Number of named arguments. } DISPPARAMS; The arguments are passed in the array rgvarg[ ], with the number of arguments passed in cArgs. The arguments in the array should be placed from last to first, so rgvarg[0] has the last argument and rgvarg[cArgs -1] has the first argument. The method or property may change the values of elements within the array rgvarg, but only if it has set the VT_BYREF flag. Otherwise, consider the elements as read-only. With best wishes, Vita -- modified at 10:36 Friday 11th November, 2005
-
Take a look into MSDN's "Passing Parameters" topic (or search for these words). From there: typedef struct FARSTRUCT tagDISPPARAMS{ VARIANTARG FAR* rgvarg;// Array of arguments. DISPID FAR* rgdispidNamedArgs; // Dispatch IDs of named arguments. unsigned int cArgs;// Number of arguments. unsigned int cNamedArgs; // Number of named arguments. } DISPPARAMS; The arguments are passed in the array rgvarg[ ], with the number of arguments passed in cArgs. The arguments in the array should be placed from last to first, so rgvarg[0] has the last argument and rgvarg[cArgs -1] has the first argument. The method or property may change the values of elements within the array rgvarg, but only if it has set the VT_BYREF flag. Otherwise, consider the elements as read-only. With best wishes, Vita -- modified at 10:36 Friday 11th November, 2005
Dear Vita , thank you so much for helping me solve the problem. The reason was in fact the order by which the args were defined , I had overlooked the requirement that , as you stated : "The arguments in the array should be placed from last to first". After having fixed this , everything works out fine now . Thank you, Rubi :-D
-
Hello Rubi, Sounds like your problem may be related to marshaling. However, if possible, it would be best if you could send me a scaled down and modified version of your COM server and client code that can re-create the problem. Please send to : bio_lim_2004@yahoo.com Best Regards, Bio.
Dear Lim, thank you for trying to help. I caused the problem by not defining the right order of parameters. Vita stated in his posting (one message entry below yours) that "The arguments in the array should be placed from last to first". As soon as I read his posting I understood that I had overlooked this requirement, which for itself is sad enough...! Defining it the proper way fixed my problem. Thank you again, Rubi :-)
-
Dear Lim, thank you for trying to help. I caused the problem by not defining the right order of parameters. Vita stated in his posting (one message entry below yours) that "The arguments in the array should be placed from last to first". As soon as I read his posting I understood that I had overlooked this requirement, which for itself is sad enough...! Defining it the proper way fixed my problem. Thank you again, Rubi :-)
Hello Rubi, No problem and congratulations on discovering the bug. Best of luck to your project. Regards, Bio.