PRB: Adding a New Method to a VB Component in MTS Breaks Existing Client (241637)
The information in this article applies to:
- Microsoft Visual Basic Learning Edition for Windows 5.0
- Microsoft Visual Basic Learning Edition for Windows 6.0
- Microsoft Visual Basic Professional Edition for Windows 5.0
- Microsoft Visual Basic Professional Edition for Windows 6.0
- Microsoft Visual Basic Enterprise Edition for Windows 5.0
- Microsoft Visual Basic Enterprise Edition for Windows 6.0
This article was previously published under Q241637 SYMPTOMS
After adding a new method or property to a class in an ActiveX DLL within a MTS package and recompiling it with binary compatibility, existing clients get one of the following error messages upon deployment of the new client package:
Run-time error '-2147467259 (80004005)':Automation error Unspecified error
-or-
Run-time error '-2147221163 (80040155)':Automation error Interface not registered
CAUSE
This is caused by the fact that when you add a new method to an existing class (interface) and compile the project with binary compatibility, Microsoft Visual Basic (VB) creates a new interface and uses a forwarding mechanism to forward calls made to methods of the old interface to corresponding methods of the new interface.
This works out well between Visual Basic clients and servers when the DLL is registered by calling DllRegisterServer (using REGSVR32.EXE). Unfortunately, the type library knows nothing about the forwarding scheme and that is where MTS Explorer gets information about the component when creating a package.
RESOLUTIONNOTE: The best solution is to avoid the practice of adding methods or properties to classes with existing clients.
To work around this problem, you can do the following:
- Create a VBR file for the upgraded component by checking the Remote Server Files checkbox on the Components tab of the Project Properties dialog box before compiling the upgraded DLL.
- Open the VBR file with Notepad.exe and find the entry that looks like the following:
HKEY_CLASSES_ROOT\INTERFACE\{313BACC6-3D8B-4029-B0D3-B5F4859CEE3E}\Forward = {485D75F2-6AC5-11D3-BB1C-00C04F8ED9F0}
The first UUID {313BACC6-3D8B-4029-B0D3-B5F4859CEE3E} is the interface ID implemented by the older version of your DLL. Make a copy of this UUID. - Start Regedit.exe and open the HKEY_CLASSES_ROOT\Interface subkey, then find the UUID you've copied.
- This UUID subkey should have three additional subkeys of its own:
- Forward
- ProxyStubClsid
- ProxyStubClsid3
- Export the UUID subkey and save it as a REG file.
- Create the MTS package with the upgraded component as usual. After you install the client package (the exe in the client folder), double-click the REG file on the client machine. This updates the client machine's registry to enable the existing client to access the upgraded component hosted in MTS on the remote server.
Modification Type: | Major | Last Reviewed: | 5/12/2003 |
---|
Keywords: | KbClientServer kbDLL kbInprocSvr kbprb KB241637 |
---|
|