Click here to Skip to main content
15,867,308 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!
I have simple OLE Automation code:
C#
[ComVisible(true)]
[ProgId("Olololo.Test")]
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[Guid("a1dd5e0f-b9e7-470f-7777-77777e44188d")]

[skip...]

public int NewWithParams(int Fix, params object[] args)
{
    return Fix;
}

vbs call:
VB
test = net.NewWithParams(777, "Let", "me", "take", "you", "on", "trip")

bin\Debug\123.vbs(17, 1) 
Microsoft VBScript runtime error: Wrong number of arguments or i
nvalid property assignment: 'net.NewWithParams'

ask: How to call automation methods with variable argument lists on CSharp?

Tnx!
Posted
Updated 5-Jan-12 10:21am
v2

1 solution

Oh my...

1) add attribute to param
public int NewWithParams(int Fix, [In, MarshalAs(UnmanagedType.SafeArray, SafeArraySubType = VarEnum.VT_VARIANT)] params object[] args)
{
    return Fix;
}


2)vbs call

test = net.NewWithParams(777, Array("Let", "me", "take", "you", "on", "trip"))


solution is (_!_)


:-(
 
Share this answer
 
Comments
Espen Harlinn 5-Jan-12 16:33pm    
5'ed!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900