C# COM call with Optional Parameter

  • Thread starter Thread starter Binder
  • Start date Start date
B

Binder

I am trying to call an ActiveX DLL written in VB6 from my C# app.

The function call has a single parameter that is declared optional.

How do I call it from C#?

The VB function is:

Public Function GetTasks(Optional ByVal lngUserCode As Long) As
ADODB.Recordset

Thanks,

Rg
 
Binder,

You will have to pass a value of zero to the method. If it was a
variant, then you would pass the value of System.Reflection.Missing.Value to
the parameter, to indicate it is truly missing. Because it is a long
though, it will get the default value of zero if it is not passed.

Hope this helps.
 
C# doesn't understand optional parameters, the CCW "eats" the optional-ness
of it. Therefore you need to pass a value every time, even as others say it
be zero or Missing.Value.
 
Back
Top