Microsoft KB Archive/269035

= BUG: Late Binding Fails on Optional Parameters in Java/COM Component =

Article ID: 269035

Article Last Modified on 6/14/2006

-

APPLIES TO


 * Microsoft Java Virtual Machine

-



This article was previously published under Q269035



SYMPTOMS
When you try to call a Java/COM method that takes an optional parameter, you may receive the following error message:

Run-time error: '450':

Wrong number of arguments or invalid property assignment



CAUSE
This error can occur when you use late-bound clients, such as Active Server Pages (ASP), because they do not have access to type information.



RESOLUTION
To work around this problem, create a Variant, and call its putEmpty method to act as the arguments that are optional and not being supplied. Refer to the &quot;More Information&quot; section for sample code.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



MORE INFORMATION
Early-bound clients such as Microsoft Visual Basic can detect when a method is not sent enough parameters; as a result, early-bound clients pass an empty VARIANT argument in the parameter's place. Late-bound clients cannot detect this because they do not have access to type information for the required method.

The following code sample demonstrates how to use the putEmpty method of a Variant to work around this problem: ...  IWebBrowser2 testBrowser = (IWebBrowser2)new InternetExplorer; ...  Variant var = new Variant; var.putEmpty; ...  testBrowser.Navigate(&quot;http://msdn.microsoft.com&quot;,var,var, var, var); ...

