Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

passing array of user defined type to COM servers

Status
Not open for further replies.

volkoff

Programmer
Mar 3, 2001
23
RU
I described struct in IDL file:
typedef [uuid(..)] struct tagUDT
{
long f1;
long f2;
} UDT;
and interface with a method:
interface ITest : IDiapatch
{
[id(1)] HRESULT TestIt([in, out] SAFEARRAY(UDT) * saUDT);
I compiled the object and registered it in COM+.
When I call it from VB, I have an error:
'Invalid procedure call or argument'
If I link the library as DLL it works.
Could you help me resolve the problem? (I don't want use VARIANT type).
 
In general, it's a bad idea to pass user-defined structures to COM+ components. They sometimes just screw-up for some unknown reason. You ought to look at finding a way to encapsulate your structure into a string, long, double, date, or other fundamental datatype.

I would suggest that you look at using XML stored in a string variable. Not only will it be more reliable, in the next release of Visual Studio XML is going to be very important, and it will be good for you to learn it.

Chip H.
 
HELLO FRIEND ,

SEE IF U WANT USER DEFINED ARRAY IN COM

U WIRTE METHOD
HAVING

MY_METHOD([in] BSTR Input ) .

IN VB U CAN PASS STRING IN THIS FUNCTION

See it will be Better if u go through
BOOK

INSIDE ATL BY MICROSOFT PRESS

SACHIN MUNDHRA
(SACHIN_JAI@USA.NET)
 
As Chip pointed out, you are much better passing your data in XML or any other form of basic variable types (integer, long, etc). I know that they say with SP4 you can pass UDTs (never tried an array of UDTs though), but I have seen it do flaky things as well as hurt performance. - Jeff Marler B-)
 
Hi,
Have you tried to define your parameter as as an OleVariant?



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top