4 Replies Last post: Oct 11, 2005 1:19 PM by Serge Piletsky  
Eric Rizzo   7 posts since
Apr 24, 2006
Currently Being Moderated

Sep 29, 2005 5:48 PM

Passing values to a variable arguments method

I am working with a simple VB COM dll that has a method expecting a ParamArray (variable number of arguments). When I run the JNIWrapper codegen tool on this DLL, I get the following interface for the COM object:

 

    _CResult runProcess(

        BStr /in/ sProcess,

        SafeArray /in,out/ vArgs)

 

Unfortunately, I can't figure out how to pass an empty array to this method (for the case when there are no additional args other than the sProcess string). I tried just null, which caused an error in the VB code. Then I tried passing new SafeArray() but that produced "Illegal access" errors.

 

Is there any additional documentation or advice for calling functions that use ParamArray for variable argument lists?

 

I could probably provide the small DLL if that would help.

 

TIA,

Eric

Serge Piletsky TeamDev Ltd. 670 posts since
Apr 24, 2006
Currently Being Moderated
1. Sep 30, 2005 2:50 PM in response to: Eric Rizzo
Re: Passing values to a variable arguments method

Hi Eric,

 

Supposing that vArgs parameter is in/out, the correct solution should be:

 

    SafeArray vArgs = new SafeArray();

    object.runProcess(new BStr("someValue"), vArgs);

 

Usually this approach works, but it is not clear why it may fail in your application. Therefore please send the DLL to investigate the problem and also please specify the version of JNIWrapper that you use.

Serge Piletsky TeamDev Ltd. 670 posts since
Apr 24, 2006
Currently Being Moderated
4. Oct 11, 2005 1:19 PM in response to: Eric Rizzo
Re: Re: Re: Passing values to a variable arguments method

Hi Eric,

 

Yes, this is correct implementation. The runProcess method is defined as following:

 

id(0x60030000), vararg

_CResult* RunProcess(

                in BSTR sProcess,

                in, out SAFEARRAY(VARIANT)* vArgs);

 

where vArgs parameter is defined as in/out array of variants. Such constructor SafeArray(0, Variant.class); just correctly initializes the type of array.

 

Unfortunately I could not test it. I have tried to reproduce the problem using the generated files for VBPOC.DLL library, but in my case the CController.create(ClsCtx.ALL); method failed with 0x80040154(Class not registered) COM exception, though the library was registered correctly. Then I tried CController.create(ClsCtx.SERVER); but just failed with another (0x800A005B) exception. Is that attached VBPOC.DLL library correct?

More Like This

  • Retrieving data ...