C# COM call with Optional Parameter

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
 
N

Nicholas Paldino [.NET/C# MVP]

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.
 
G

Guest

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top