Microsoft KB Archive/233359

= FIX: JActiveX fails for COM Property Declared as IUnknown =

Article ID: 233359

Article Last Modified on 11/14/2005

-

APPLIES TO


 * Microsoft Visual J++ 6.0 Standard Edition
 * Microsoft Java Virtual Machine
 * Microsoft Software Development Kit for Java 1.51
 * Microsoft Software Development Kit for Java 2.02
 * Microsoft Software Development Kit for Java 3.2
 * Microsoft Software Development Kit for Java 2.01
 * Microsoft Software Development Kit for Java 2.02
 * Microsoft Software Development Kit for Java 3.0
 * Microsoft Software Development Kit for Java 3.1

-



This article was previously published under Q233359



SYMPTOMS
The following error is generated when trying to build a Java project that imports a COM component whose property is declared as type IUnknown:

Undefined name 'stdole2.IUnknown' (J0049)



CAUSE
The problem is that JActiveX generates Java code that treats IUnknown as a user-defined type, rather than as com.ms.com.IUnknown.



RESOLUTION
The problem has been fixed for the JActiveX.exe version 3549 that is included with the SDK For Java version 3.2. For more information, visit the following Microsoft Web site:

http://www.microsoft.com/mscorp/java/

However, if you are still using a JActiveX prior to SDK3.2, you could still work around the problem using either of the following two ways:  Declare the property as Object in Visual Basic. It will then be exposed as IDispatch in the type library and Object in Java.  Use a configuration file that will tell JActiveX to use com.ms.com.IUnknown for all types with a GUID of IID_IUnknown. The config file will look like the following: ; IUnknown! [{00000000-0000-0000-C000-000000000046}] Use Class=com.ms.com.IUnknown   If the configuration file were called mappings.jnf, JActiveX would be invoked like this: jactivex /d. /javatlb /t mappings.jnf MyControl.DLL  Note that the stdole2 package will not be created because there are no referenced types.



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

<div class="moreinformation_section">

MORE INFORMATION
Here is a sample case that reproduces the problem. In the following example, the COM component is an ActiveX DLL created using Visual Basic 6.0. This DLL implements a property declared to be of type IUnknown. When you run JActiveX or do an AddCOMWrapper from within Visual J++ 6.0, it treats this property IUnknown as a user-defined type rather than as com.ms.com.IUnknown. The problem is that Visual Basic is marking the IUnknown property type as a user-defined type (VT_USERDEFINED) instead of the usual IUnknown (VT_UNKNOWN).

Steps to Reproduce Behavior
  Create an ActiveX DLL (say Project1.dll) using Visual Basic 6.0, and include the following code: Public Property Get NewEnum As IUnknown Set NewEnum = Nothing End Property

</li> Create a Windows Application using Visual J++ 6.0.</li> Select Project.Add COM Wrapper.</li> In the COM Wrappers dialog box, select the Project1.dll created in step 1.</li> This will create two wrapper class files, project1 and stdole2.</li> Build the application .</li> You see the above mentioned error.</li></ol>

Keywords: kbbug kbfix kbjava kbcompiler KB233359

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.