Microsoft KB Archive/190460

= PRB: Type Mismatch Error in Client After Modifying Server DLL =

Article ID: 190460

Article Last Modified on 3/3/2005

-

APPLIES TO


 * Microsoft Visual Basic 6.0 Learning Edition
 * Microsoft Visual Basic 6.0 Professional Edition
 * Microsoft Visual Basic 6.0 Enterprise Edition

-



This article was previously published under Q190460



SYMPTOMS
If an ActiveX DLL server has two classes and one class implements the other, running a compiled client project referencing the server will generate the following error after modifying and recompiling the server with binary compatibility:

Run-time error 13: Type mismatch



RESOLUTION
Reopen the client project and compile it again.



STATUS
This behavior is by design.



Create the Server
 Start a new ActiveX DLL project in Visual Basic. Class1 is created by default. Select Project1 Properties from the Project menu and change the Project Name to "Server." Select Add Class Module from the Project menu to add Class2 to the project.  Paste the following code in Class2: Public Sub Test End Sub   Paste the following code in Class1: Implements Class2

Private Sub Class2_Test MsgBox "Testing the Server" End Sub

 Select Make Server.dll from the File menu to compile the project.</li> Save the Server project files.</li></ol>

Create the Client
<ol> Start a new Standard EXE project in Visual Basic 6.0. Form1 is created by default.</li> Select Project1 Properties from the Project menu, and change the Project Name to "Client."</li> Select References from the Project menu, and select "Server."</li>  Paste the following code in Form1's code module: Private Sub Form_Load Dim x As Server.Class2 Set x = New Server.Class1 TestMethod x     End Sub

Private Sub TestMethod (x As Server.Class2) x.Test End Sub

</li> Select Make Client.exe from the File menu.</li></ol>

Test the Client with the Server
<ol> Run Client.exe outside the Visual Basic design environment. The program runs correctly.</li>  Reopen the Server.dll project and add the following code to Class2: Public Sub Test2 End Sub

</li>  Add the following code to Class1: Private Sub Class2_Test2 End Sub

</li> Select Server Properties from the Project menu, and select the Binary Compatibility option on the Component tab.</li> Select Make Server.dll from the File menu to compile the project. Overwrite the existing Server.dll.</li> Run Client.exe again. Note that the following error occurs:

Run-time error 13: Type mismatch

</li> To resolve this, recompile the client, overwriting Client.exe. Run Client.exe and note that no error occurs.</li></ol>

Additional query words: kbdss kbDSupport kbVBp kbVBp600 kbCompiler

Keywords: kbprb kbcompiler KB190460

-

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

© Microsoft Corporation. All rights reserved.