views:

908

answers:

4

We upgraded our machines with a microsoft patch listed above and are now having issues with some winsock controls. While moving on to the new component library there were two issues that we faced:

  • We are creating a Winsock control dynamically using Form.Controls.Add(...). With the new dlls it gave us a run time error 731 stating that we needed to add the license.

This issue was resolved by adding a line License.Add(PrgID of the control) before adding the control.

Now the issue is when we try setting this control to an object of type mWinsock we get a runtime error Type Mismatch. Any thoughts?

Thanks, Abhay

+1  A: 

You may need to add the control to the toolbox so that the VB6 project and form has a proper reference to it. You will need to do this even if you don't actually have it on the form at design time.

With the reference VB may not have all the information needed to resolve the methods and properties of the control at run-time

RS Conley
A: 

Since the interface signatures have changed, you will have to remove the component reference from the project, save and close VB6 completely, unregister the old control, register the new version from the patch, reopen your project and add the component back in. If you do this you'll most likely lose support for machines that don't have the patch installed (or you will have to install it as part of your installation package)

Of course, you can always declare the reference "As Object" if it's easier but your performance will drop a bit and you will lose support for WithEvents

rpetrich
What component libraries had interface changes?I have tested a few of them by unpacking the MSI to a folder, then manually copying the new libraries over the original ones in Reg-Free COM packages without changing any interface information in the EXE's manifest. So far all work w/o any change.
Bob
According to the OP, the Winsock OCX interface has changed. I'm not sure exactly how it changed, but one could find out by extracting the type library from both versions and comparing them.
rpetrich
+1  A: 

Take a look at "Description of the cumulative update rollup for the Visual Basic 6.0 Service Pack 6 Runtime Extended Files."

http://support.microsoft.com/kb/957924/

This December 30, 2008 update should remove and replace the faulty Dec 9 security update. It appears to deal with both 926857 and 957924.

958369 seems to be a Visual FoxPro KB article for the same faulty update (Dec 9). VFP uses many VB controls.

Bob
A: 

I encountered a similar issue when dynamically creating non-intrinsic controls in VB6. Perhaps Winsock is no longer considered intrinsic. Try declaring your variable as VBControlExtender instead of Winsock, as follows:

Option Explicit
Dim WithEvents objExt As VBControlExtender

Private Sub LoadControl()
   Licenses.Add "MSWinsockLib.Winsock", "xydsfasfjewfe"
   Set objExt = Controls.Add("MSWinsockLib.Winsock", "myCtl")
End Sub

Private Sub extObj_ObjectEvent(Info As EventInfo)
   ' Program the events of the control using Select Case.
   Select Case Info.Name
     Case "DataArrival"
       ' Do stuff
   End Select
End Sub

See this MSDN article for more information.

Templar