BUG: Late Binding Fails on Optional Parameters in Java/COM Component (269035)



The information in this article applies to:

  • Microsoft 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 "More Information" 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("http://msdn.microsoft.com",var,var, var, var);
   ...
				

REFERENCES

For support information about Visual J++ and the SDK for Java, visit the following Microsoft Web site:

Modification Type:MajorLast Reviewed:6/14/2006
Keywords:kbBug kbFAQ kbJava kbnofix KB269035