Hi all!!

I have been having a weird problem. I am writing an ActiveX EXE server that
serves both as a VB5 AddIn and a stand-alone executable. Believing in the
reuse of GUI as well as code, I naturally used a private UserControl to
implement the majority of the functionality, and put simple delegation code
onto a form and an UserDocument in order to cope with its two uses.

Now, everything was working alright, and for the first main version, it was
working and compiling quite nicely. Later on, after a few enhancements, I
decided to another build, and during the build, I suddenly got an error
message "Automation Error". From experience, I have found that getting
these type of error messages during a build means that there is some dodgy
code in the UserControl_Initialize or UserControl_Terminate events, which is
executed due to the UserControl for some reason being actually instantiated
during compilation. Well, I had deliberately moved a whole lot of code from
the UserControl_Initialize event to a procedure called Init - called from
the UserControl_ReadProperties and UserControl_InitProperties event
procedures - just for this reason. After some debugging, it looked as if
both the Initialize and Terminate events were working OK. During debugging,
I was getting (with ObjPtr(Me))

UserControl_Initialize:6536904
UserControl_Terminate:6536904

----> AUTOMATION ERROR

At which point, it told me that it couldn't load a temporary file, and would
ask me whether I wanted to continue. Saying yes at this point would cause
the same error to occur again:

UserControl_Initialize:6536904
UserControl_Terminate:6536904

----> AUTOMATION ERROR

(Obviously the Form, then the UserDocument).

If you subsequently tried to open the Form or the UserDocument, the
UserControl there would be an error message - the same one! - and then the
UserControl would have turned into a picture box.

Bizarrely, if you <didn't> open the Form or UserDocument again, you could
try to compile the project again - but this time it would work! But if you
ran the executable, then you would get an error:

"Run-time error '363':"

"ActiveX control 'PVResourceStringsViewer.XStrings' not referenced in this
project. Use Project/Components... to add a reference."


All this seemed to be a problem with CLSIDs, so I decided to remove Binary
Compatibility - and surprise! - the thing compiled:

UserControl_Initialize:6536904
UserControl_ReadProperties:6536904
UserControl_Resize:6536904
UserControl_WriteProperties:6536904
UserControl_Terminate:6536904
UserControl_Initialize:6536904
UserControl_ReadProperties:6536904
UserControl_Resize:6536904
UserControl_WriteProperties:6536904
UserControl_Terminate:6536904

Unfortunately, I cannot subsequently, whatever I do, compile with Binary
Compatibility.

Can anybody help me?

--
Mark Alexander Bertenshaw
Programmer/Analyst
PrimeResponse
Brentford
UK