Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

supertecho prob. VB changing Object IDs on compile

Status
Not open for further replies.

thesleepylizard

Programmer
Mar 18, 2002
41
AU
Hi everyone,

I have an ActiveX Control which I wrote and maintain in VB6 - it compiles to a OCX file which I can include in the components screen in other programs. (I'll call it SuperGrid.OCX, containing a UserControl called SuperGrid)

OK. Here's the visible problem: If I need to make a change to the ActiveX control, I open up the VB project for it, make my change, and compile again to the OCX file. Then, after that, when I try to open another VB project which includes this OCX file in the components window, I get the message:

Code:
"C:\SuperGrid.OCX" could not be loaded -- Continue Loading Project?

Clicking yes brings up many error messages like:

Code:
Errors during load. Refer to frm***.log for details

It gives that error message for each form that uses SuperGrid. I found I can get it up and running again by clicking through each of the error messages, then going into Components and ticking SuperGrid again, and then going into each form that used SuperGrid and inserting the control again. But with 15 screens using it, I'll have to do this each time I make a change and recompile SuperGrid. Kinda... annoying.

====Now for the technical garb.====

I've done some digging around. I'm not 100% clued up on ActiveX, and object IDs and versions and things, but, here's what I've found:

In the myprogram.vbp file, it contains a reference to SuperGrid along the lines of:

Code:
Object={3848C8C9-D789-3A77-3838-93F101A9ACB6}#3.0#0; SuperGrid.ocx

The first series of number appears to be the unique class ID, the after that we have #3.0#, which appears to be the version number, and after that I'm not sure what that number is.


NOW, I created a seperate dummy activeX control to try and diagnose what the problem was. I could recompile it to Dummy.OCX, open up a seperate project which included Dummy.OCX, and the class ID recorded in the dummyproject.vbp file wouldn't change. (The version number changed, which VB mentioned when it loaded up, but the class ID never changed, no matter how many times I recompiled). That is correct - the class ID shouldn't change.


But, I performed exactly the same test with my SuperGrid, and I found that when I recompiled it, (drum roll.....) THE CLASS ID HAD CHANGED!!!!!

Summary in techo terms: Each time VB recompiles my SuperGrid.OCX, it is assigning it a new class ID, which is disrupting references to it in other projects.

This is bad, this is wrong, this is a NO NO. This is what is making VB fail to recognize it in other projects - it's still got the reference to SuperGrid.OCX, but because the class ID recorded in myprogram.vbp is different from the class ID in the recently recompiled SuperGrid.OCX, it is (quite rightly) not recognizing it as the same file.

The problem is certainly in the compile, when it's assigning it a new class ID - not in the other project where it's using it, and failing upon loading.
================================================

I hope this makes sense - I hope I've described the problem clearly. I'm thinking of writing a quick program which will scan all the files in my project for references to the old class ID and just insert the new class ID, but really, this is a last resort and I'd prefer a proper solution.

Does anyone know about this? Has anyone else had the same problem? How do I get around this?

Thanks for your time, and thanks for reading through all this.
-Sleepy
 
For everyone's interest, I have got around the problem by moving all of the code and stuff in SuperGrid.OCX into a new, blank project, and compiling it from there instead of the old location. This works fine, and I'm happy.

Wierd...
 
Hi,


The problem has to do with compatibility. If we check the properties of the control's project you will see that there are several choices for compatibility: None, binary, and something else. These actually control when the control gets a new CLSID. Not sure of all the nuances, but "no compat" I think changes the CLSID every time, "binary" never changes the CLSID, not sure about the other choice.

Anyway I was going nuts with this for a while till we got it figured out. I maintain a control which somelse wrote, I'm mostly a unix/c guy, and sometimes this stuff drives me nuts. It looks like simplistic drag and drop, but once something goes wrong, you are exposed to endless layers of complexity and black magic.

 
Thanks a heap for that jorma! I'm glad I know I'm not the only who's had the problem in the past. I'll keep this in mind for the future.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top