FIX: VJ6 COM DLL: Function/Interface Marked Restricted or Automation Type Not Supported in VBID: Q214409
|
The following error occurs when you try to use a Java COM DLL in Visual Basic (using early binding):
Compile error :
Function or interface marked as restricted,
or the function uses an Automation type not supported in Visual Basic
Invalid method prototypes are generated in the DLLs type library (*.tlb). The return type "VARIANT" is mistakenly listed as "VARIANT *". Visual Basic uses the .tlb to resolve parameter and return types at compile time.
This problem has been fixed in the Microsoft virtual machine versions 3158 and higher.
To fix the problem for older versions of the Microsoft virtual machine, do one of the following:
import com.ms.com.*;
/** compiled to 'Project2.dll'
* @com.register ( clsid=151A5839-A724-11D2-B1B9-00C04FC22764, typelib=151A583A-A724-11D2-B1B9-00C04FC22764 )
*/
public class MyCOMClass {
private Variant m_variant = new Variant("Merry Christmas");
public void MyCOMClass( ) {
}
public Variant getPhrase( ) {
return m_variant;
}
}
Private Sub Command1_Click()
Dim vj As Object
Set vj = CreateObject("Project2.MyCOMClass")
Text1.Text = vj.getPhrase
End Sub
Public vj As New Project2.MyCOMClass
Private Sub Command1_Click()
Text1.Text = vj.phrase
End Sub
This problem has been fixed in the Microsoft virtual machine versions 3158 and higher.
Method 1 works because you bypass the .tlb when you connect to the DLL at run time.
Method 2 works because you named the COM DLLs public method get<Something>. When a name that starts with "get", the balance of the method name is used as a property for the object. In this case, the method getPhrase is added to the .tlb twice: once as "VARIANT *getPhrase()" and again as "VARIANT phrase()".
Method 3 works because you are actually correcting the typo by hand.
For the latest Knowledge Base articles and other support information on Visual J++ and the SDK for Java,
please see the following pages on the Microsoft Technical Support site:
http://support.microsoft.com/support/visualj/
http://support.microsoft.com/support/java/
© Microsoft Corporation 1999, All Rights Reserved.
Contributions by Joseph B. Hall, Microsoft Corporation
Additional query words: Function interface marked restricted Automation Type Not Supported IDL TLB early late binding
Keywords : kbCOMt kbJavaVM kbVBp600 kbVJ600bug kbVJ600fix kbGrpJava
Version : WINDOWS:6.0
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: July 28, 1999