Loading & Using VisualBasic 6 Legacy Projects on Windows 7 - How To Register Legacy Typelibs on Modern Microsoft OS (Kim Gentes/Worship Tech Blog)
This tech blog post will be for the programmer geeks out there.
Recently, I have had to go back to reinstalling Visual Basic 6 on a Windows 7 workstation and trying to do some development/bug fixes. Specifically, I have been trying to get my dev environment working to debug some old VB6 OCX projects. After working through some initial lameness with installing VB6 (for example, it will always try to install an old version of Java on a new Windows machine- you can trick it out of doing that), I final got VB6/studio installed and could open my old VB6 project. A few more obvious issues after that, I was down to one error that I couldn't seem to solve.
The Problem
When I opened any of the VB6 projects, I got the same series or errors trying to load the project. I have included the screen shots in detail here so you know exactly what I am seeing. I went through various Google and MSDN recommendations but nothing was working and I did not find a solution. Here were the errors I was getting:
...continue loading project?
Errors during load. Refer to '<path>.log' for details.
Errors occurred during load.
Errors during load. Refer to '<path>.log' for details.
The project finally appeared, but without some of the MS Controls that I had used in the project.
The error log file referred to in the screen shots contained this kind of error in my project (yours will vary):
Line 12: Class MSComctlLib.Slider of control sldInterval was not a loaded control class.
Line 37: Class MSComctlLib.Slider of control sldCallTimeout was not a loaded control class.
Line 54: Class MSComctlLib.Slider of control sldConnectTimeout was not a loaded control class.
Line 71: Class MSComctlLib.Slider of control sldTimeoutPeriod was not a loaded control class.
Line 88: Class MSComctlLib.Slider of control sldRetryPeriod was not a loaded control class.
The real problem? The Microsoft Visual Basic 6.0 Common Controls ( MSCOMCTL.OCX ) was not properly registered. OK. No problem, I thought. So, I quickly went to my Windows/SysWow64 directory and I registered it by running:
> regsvr32 mscomctl.ocx
from the command line (as Administrator). Command shell responded that .ocx was registered successfully. Woohoo!
Only, once I re-loaded the VB6 project, I got the same error as before: "Object library not registered"
So, I thought I might have to force VB6 studio to re-associate with the OCX so I attempted to add the mscomctl.ocx file to the project via the Components menu in the IDE. No tamales. Response: "Object not registered". I even tried reinstalling VB6. No dice either. Bummer.
The Resolution
As I said, re-registering the OCX or reinstalling VB6 didn't help.
Back to Google and MSDN. I found a couple articles online that said to re-register the typelib as follows for Windows 7--
> cd C:\Windows\SysWOW64\
> regtlib msdatsrc.tlb
This apparently works on some computers, but on my machine as the "regtlib.exe" executable was not present in the SysWow64. In fact, that file as an exe does not exist on my machine. After a bit more searching, I found that the type library registration is now part of .NET framework. I had to use that equivalent binary inside of one of my installations of .NET to do the task. On my machine, the solution was as follows:
> cd C:\Windows\SysWOW64\
Once there, I ran the regtlib command from the .net version that is installed (latest) on my machine.
> C:\Windows\SysWOW64]C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regtlibv12.exe msdatsrc.tlb
Registration of msdatsrc.tlb successful.
This command ran successfully and now I can open my VB project. Zippidee doooda! Now my VB 6 project loads successfully.
Since this took me a while, I assumed others may have run into this gauntlet, so I wanted to be sure to document the fix in case anyone else runs into this.
Keep on coding people...
Kim Gentes
References (2)
-
Response: Best Project tracking softwareBest project management software & enterprise project portfolio management (PPM) tools of 2024 that offer robust features, customizable solutions at best pricing.
-
Response: Microsoft Project vs Monday.comMicrosoft Project vs Monday.com vs Celoxis: Comparison of the best project management software for enterprises, teams, resources, & business goals.
Reader Comments (8)
great
Dear Kim,
Thank you soooo much!!
Dear Kim,
Thank you very much. I was pretty sure to go through the whole process, as you did. But lucky me, this was not necessary ;-).
Got it running on a Virtual Machine in Win7 and VB 6 by your final "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\regtlibv12.exe msdatsrc.tlb"
Great!
Frederik
Thanks Kim,
I looked around very much before finding the solution in your article. Thnks.
Good on You Kim,
Found your post after struggling for 7 hrs, finally issue ben resolved.
Thank you.
glad this is helping, Suresh. Thanks for the note..
YOU ARE A GOD SEND !
Digital Monk Marketing offers top-tier Hamilton SEO services, helping businesses increase their search engine visibility and drive organic traffic. Their tailored SEO strategies focus on improving local rankings, enhancing online presence, and delivering sustainable business growth.