1
votes

I have an old VB6 project that uses a CTL user control. I can see the user control on the toolbox.

If I create a new form inside the project, and I try to add the user control, it fails because "Error loading DLL" and the control cannot be added.

But if I create a new project, I can add the user control to the project, and then use it in a new form without problem.

What is wrong in the first project, that I cannot use the user control in its forms?

In the same way, opening the forms of the project where the user control is already used, the control is not recognized. Seems something related to a wrong path/reference for the user control on the original project.

I've tried to add the user control again, but it tells me that already exists a user control with the same name.

And if I try to quit the user control to load it again, I cannot quit it because is being used in the project. What can I do?

Thanks for your help.

2
The project could have a missing reference.R.J. Dunnill
Is there any code in the CTL at all which references classes in other DLLs? This could be through a CreateObject call, for instance.StayOnTarget

2 Answers

1
votes

Open your CTL file in a text editor (Notepad will do fine).

At the top it may have lines similar to the following:

VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFlxGrd.ocx"

There may be one or more Object= lines.

It is likely that at least one of the files referred to one these lines is either missing or not registered on the computer.

0
votes

Don't ask me why, but the only way to succeed was to start from scratch. I've started with a clean Windows XP laptop with Visual Studio SP6 installed.

When trying to load and compile the project, the same error appeared. The same if I tried to draw a new instance of my user control: Error loading DLL And the same if I tried to open a Form with instances of my user control inside: the control was not recognized in the form (empty areas).

So, I started a new empty ActiveX DLL project. Adding all the objects step by step, I could load all of them (with some small problems) but finally I could compile the project.

The order for adding the objects was important: References & Components, User Controls, Modules & Classes, Designers, and finally Forms.

I was trying to compile on each step to catch the reason of the problem, and to know the next object that had to be added. But don't understand exactly why it works now. Thanks anyway!

EDIT 2018-11-07:

I've discovered a work around on the initial project, to use the CTL user control without problem, and to compile the project without any error message. I want to share it here to help anybody with a similar problem.

I don't know why, maybe anybody can give an explanation, but if I open the project, and then open the designer called frmDate (see the image), from that moment then I can compile the project, and use the user control on any form. What is going on??

enter image description here