DOCUMENT:Q184322 23-APR-1998 [vbwin] TITLE :BUG: Error "438" When Implementing Base Class in ActiveX Exe PRODUCT :Microsoft Visual Basic for Windows PROD/VER:WINDOWS:5.0 OPER/SYS:WINDOWS KEYWORDS: ====================================================================== --------------------------------------------------------------------- The information in this article applies to: - Microsoft Visual Basic Control Creation, Learning, Professional, and Enterprise Editions for Windows, version 5.0 --------------------------------------------------------------------- SYMPTOMS ======== If you late-bind to an ActiveX EXE that contains a derived class that implements a base class, you receive the following error when trying to use a method or property of that base class: Run Time Error "438" Object Doesn't Support This Property Or Method RESOLUTION ========== Use early binding or put the base and derived classes into an ActiveX DLL. STATUS ====== Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available. MORE INFORMATION ================ Steps To Reproduce ------------------ Part 1 ------ 1. Start a new ActiveX EXE Project in Visual Basic 5.0 2. On the Project menu, click Project1 Properties, and change the name of the ActiveX EXE project to "OutProcServer". 3. Add two additional class modules to the Project. Name the existing three class modules as follows: clsBase clsDerived clsStarter 4. Paste the following code into the clsBase module: Property Get MyFirstProperty() As String End Property 5. Paste the following code into the clsDerived module: Implements clsBase Private Property Get clsBase_MyFirstProperty() As String clsBase_MyFirstProperty = "Hello from MyFirstProperty!" End Property 6. Paste the following code into the clsStarter module : Public Function CreateDerivedClass() As clsBase Set CreateDerivedClass = New clsDerived End Function 7. Save the ActiveX EXE project, and then compile it. Part 2 ------ 1. Create a new Standard EXE project, Form1 is created by default. 2. On the Project menu, click References, then select "OutProcServer," which is the server that was just compiled step 7 of Part 1 above. 3. Add two Command Buttons to Form1 (Command1 and Command2). 4. Paste the following code into the code module of Form1: ' Early bound object references. Dim oEarlyStarterClass As OutProcServer.clsStarter Dim oEarlyDerivedClass As OutProcServer.clsBase ' Late bound object references. Dim oLateStarterClass As Object Dim oLateDerivedClass As Object Private Sub Command1_Click() ' Create an instance of the out-proc server starter class object. Set oEarlyStarterClass = New clsStarter ' Now that there is a reference to the starter class object; use ' this object to return an instance of the derived class, which ' implements the base class declared in the out-proc server. Set oEarlyDerivedClass = oEarlyStarterClass.CreateDerivedClass ' Show the object type of the newly created object returned ' from the starter class object; it will be the derived class. MsgBox "oEarlyDerivedClass Is Of Type : " & _ TypeName(oEarlyDerivedClass) ' To prove that an instance of the derived class was successfully ' created, call the base class's interface, which the derived ' class implemented. MsgBox oEarlyDerivedClass.MyFirstProperty ' Destroy our objects. Set oEarlyDerivedClass = Nothing Set oEarlyStarterClass = Nothing End Sub Private Sub Command2_Click() ' Create an instance of the out-proc server starter class object ' late-bound. Set oLateStarterClass = CreateObject("OutProcServer.clsStarter") ' Create a late-bound instance of the derived class. Set oLateDerivedClass = oLateStarterClass.CreateDerivedClass ' The first test is to show the type of the object that was just ' created through the starter class object. The MsgBox will show ' the correct value; which is the derived class, and not the base ' class. MsgBox "oLateDerivedClass Is Of Type : " & TypeName(oLateDerivedClass) ' Finally, try to call the property that the derived class ' has implemented. This will fail! MsgBox oLateDerivedClass.MyFirstProperty End Sub 5. Press F5 to run the project. 6. Click the Command1 button; this creates an instance of the "Starter Class." The Starter Class is used to create an instance of the derived Class. The Starter Class then checks to make sure that the proper class is being returned, and then calls the base class's property. This test uses early binding. 7. Click the Command2 button; similar to the Command1 button, the Command2 button creates an instance of the "Starter Class." This class then returns an instance of the derived class, then checks that that the proper object type is returned. Calling the base class property results in the 438 error. This second test uses late binding, and fails when it should succeed. Additional query words: ====================================================================== Version : WINDOWS:5.0 Platform : WINDOWS Issue type : kbbug Solution Type : kbpending ============================================================================= THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY. Copyright Microsoft Corporation 1998.