2
votes

We have an old VB6 project that uses ActiveX controls, some of which we build and others we get from third-party vendors.

Currently, we use a .csproj project which does the following,

  • Execute regsvr32 to register the OCXs
  • Execute vb6 to build the VB6 project
  • Execute regsvr32 to unregister the OCXs

This registering/unregistering is ugly and is a bit of a pain for local developer builds with UAC enabled. Is it at all possible to build a VB6 project without having to register any controls?

I apologize if this has already been asked before. The only similar questions I was able to find were about how to build VB6 projects, and answers to these mention the same solution of register, build, unregister.

3
You are probably doing better than I, similar process used but with a .bat script. - tcarvin

3 Answers

1
votes

It sounds like these people are merely working on clients of these OCXs rather than modifying and recompiling the OCXs themselves.

If so, you should be administering the installation of these libraries just as you administer the VB6 development system itself. This means each workstation needs to have the control suites you are using installed once (well, and maintained when new releases are placed into use). Installers for developer libraries deploy things like .DEP files as well as design-time license key registry entries, so using regsvr32 shouldn't be considered a viable strategy anyway.

If you set the developer workstations up properly and maintain them there isn't any reason to be registering and unregistering such things.

1
votes

It means the original developers probably did not set the "binary compatibility" correctly. Which means the VB6 dll's get a "new com guid" every time they are built. Which means your original VB6 developers were probably a bunch of hacks.

You can read the section here on Binary Compatibility.

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

Get in a time machine and go back and punch the person in the face who said "We don't need to work out the binary compatibility issues now, we'll just unregister and re-register the components... Easy Peezey!"................

If I'm wrong, please let me know. But every time I've seen "unregister the com" and "re-register the com".........it goes back to that brainiac decision.

Here is a longer discussion on it:

http://www.techrepublic.com/article/demystifying-version-compatibility-settings-in-visual-basic/5030274

EDIT:

If the ocx's are not changing........then you should only have to register them once on the build machine once.

0
votes

The direct answer is no, it is not possible to compile a VB6 project with OCX dependencies without those dependencies being registered.

Furthermore, the act of compilation itself involves VB6 attempting to register what it has just built (unless you are compiling to an EXE). This generally requires the VB6 IDE and/or its compiler to run with "admin" permissions. Therefore the permissions are a hard to avoid issue regardless.

I believe these issues can be obfuscated by the fact that VB6 itself (the IDE and/or the runtime) will sometimes try to automatically register certain things for you, but will keep silent when it does so.


You should probably create a different process to setup a development PC from the build process you use from deployment. This may "feel" wrong especially if you have experience with other programming environments, but I would stress that VB6 can be very painful & problematic to work with and so pragmatism is generally in order.

On the development PCs: Setup all the unchanging dependencies once (and document them) and then leave them alone (as noted in another answer.) When weird dependency problems occur, verify the PC is setup correctly before doing anything else.

If you have all the sources to your dependencies, then I would consider if you can actually run them all in a VB6 project group (VBG) and not compile them at all. (A VBG is akin to a .NET solution though far less powerful.) I do this often and it cuts out a lot of wasted time. Developers don't necessarily need code compiled to EXE / DLL / OCX - they often just need to be able to run it in the IDE.

On the build PC: If you can always start with a clean environment, like in a virtual machine, then I think its actually a good idea to register everything from scratch in an automated fashion as this helps to verify nothing is missing or mismatched. Re-using the same build environment without doing this can mask problems when some dependency has changed in source control but still exists on the build machine. On a VM generally permissions aren't a limiting factor.


Notes:

  • If you are building an EXE, VB6 does not require any elevated permissions, as far as I can recall.

  • Running code in the VB6 IDE does not either.


[Caveat 1]:

It may technically be possible to create a side-by-side application manifest file for VB6.exe itself and include in that manifest whatever dependencies you need, thereby avoiding having to register them.

But this would fall well outside of the normal ways to use VB6 tools - its a hack - and possibly is not worth the potentially large effort. I don't think I've ever seen a working example and so I don't recommend this as a practical solution, but mention it for completeness.

Maybe in some locked-down corporate IT scenario this could pay off... maybe. In that scenario doing dev work in a VM might be a better option though.