"Automation Error" when compiling application using private UserControl.


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 10 of 10

Thread: "Automation Error" when compiling application using private UserControl.

  1. #1
    Mark Alexander Bertenshaw Guest

    "Automation Error" when compiling application using private UserControl.

    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



  2. #2
    Michael Culley Guest

    Re: "Automation Error" when compiling application using private UserControl.


    Mark,

    I had a similar problem when compiling. I cannot remember the exact cause
    but I solved it by putting messageboxes in UserControl_init/readprops etc
    until I tracked down the line of code that was causing the problem. From
    memory something was different when compiling as opposed to opening or running
    a form. Maybe the events fired in a different order or an event was missed
    or the control didn't have a client site when normally it would.

    Hope this helps

    Michael Culley

    "Mark Alexander Bertenshaw" <mark.bertenshaw@virgin.net> wrote:
    >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
    >
    >



  3. #3
    Mark Alexander Bertenshaw Guest

    Re: "Automation Error" when compiling application using private UserControl.


    Michael -

    Thanks for replying. Unfortunately, even if I remove ALL code from the UserControl
    events, I still get Automation Error. Also, your experience didn't seem to
    have anything to do with Binary Compatibility.

    -------------------------
    Mark Alexander Bertenshaw
    Programmer/Analyst
    Prime Response
    Brentford
    UK


    "Michael Culley" <m_culley@one.net.au> wrote:
    >
    >Mark,
    >
    >I had a similar problem when compiling. I cannot remember the exact cause
    >but I solved it by putting messageboxes in UserControl_init/readprops etc
    >until I tracked down the line of code that was causing the problem. From
    >memory something was different when compiling as opposed to opening or running
    >a form. Maybe the events fired in a different order or an event was missed
    >or the control didn't have a client site when normally it would.
    >
    >Hope this helps
    >
    >Michael Culley
    >
    >"Mark Alexander Bertenshaw" <mark.bertenshaw@virgin.net> wrote:
    >>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
    >>
    >>

    >



  4. #4
    Mark Alexander Bertenshaw Guest

    Re: "Automation Error" when compiling application using private UserControl.


    Subsequently, I have decided to look at exactly what I am keeping compatibility
    with - and it is really weird!!

    First of all, I hadn't realised that UserDocuments inherit directly from
    IDispatch, and do not have a companion v-table interface. More unusual, however,
    it seems as if there is a whole load of hidden methods in the _Connect interface:

    interface _Connect : IDispatch {
    [restricted] void Missing7();
    [restricted] void Missing8();
    [restricted] void Missing9();
    [id(0x6003000a)]
    HRESULT AddToAddInCommandBar(
    [in, out] BSTR* sCaption,
    [out, retval] CommandBarControl** );
    };


    But more dramatically, the UserDocument interface, _DStrings, has these methods:


    interface _DStrings : IDispatch {
    [restricted] void Missing7();
    [restricted] void Missing8();
    [restricted] void Missing9();
    [restricted] void Missing10();
    [restricted] void Missing11();

    ...... [lots of lines] .......

    [restricted] void Missing475();
    [id(0x68030000), propget]
    HRESULT XStrings([out, retval] IDispatch** );


    This really beats me!!

    Any further suggestions?

    -------------------------
    Mark Alexander Bertenshaw
    Programmer/Analyst
    Prime Response
    Brentford
    UK

  5. #5
    Michael Culley Guest

    Re: "Automation Error" when compiling application using private UserControl.


    Mark,

    Just a thought - in order to gain type info of the Bin Compat file wouldn't
    it have to instantiate it. So maybe the error is because it cannot load the
    Bin Compat copy? Can use use this copy in a project?

    Michael Culley

    "Mark Alexander Bertenshaw" <mark.bertenshaw@virgin.net> wrote:
    >
    >Michael -
    >
    >Thanks for replying. Unfortunately, even if I remove ALL code from the UserControl
    >events, I still get Automation Error. Also, your experience didn't seem

    to
    >have anything to do with Binary Compatibility.
    >
    >-------------------------
    >Mark Alexander Bertenshaw
    >Programmer/Analyst
    >Prime Response
    >Brentford
    >UK
    >
    >
    >"Michael Culley" <m_culley@one.net.au> wrote:
    >>
    >>Mark,
    >>
    >>I had a similar problem when compiling. I cannot remember the exact cause
    >>but I solved it by putting messageboxes in UserControl_init/readprops etc
    >>until I tracked down the line of code that was causing the problem. From
    >>memory something was different when compiling as opposed to opening or

    running
    >>a form. Maybe the events fired in a different order or an event was missed
    >>or the control didn't have a client site when normally it would.
    >>
    >>Hope this helps
    >>
    >>Michael Culley
    >>
    >>"Mark Alexander Bertenshaw" <mark.bertenshaw@virgin.net> wrote:
    >>>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
    >>>
    >>>

    >>

    >



  6. #6
    Mark Alexander Bertenshaw Guest

    Re: "Automation Error" when compiling application using private UserControl.


    Michael -

    "Michael Culley" <m_culley@one.net.au> wrote:
    >Just a thought - in order to gain type info of the Bin Compat file wouldn't
    >it have to instantiate it. So maybe the error is because it cannot load

    the
    >Bin Compat copy? Can use use this copy in a project?


    Nice idea - and you got me going for a while. Unfortunately, that wasn't
    it (and, of course, you don't need to instantiate anything, since type libraries
    are windows resources).

    Thanks all the same,

    -------------------------
    Mark Alexander Bertenshaw
    Programmer/Analyst
    Prime Response
    Brentford
    UK

  7. #7
    Mark Alexander Bertenshaw Guest

    Re: "Automation Error" when compiling application using private UserControl.


    Further question for anybody:

    Since I seem unable to create binary compatibility via compilation - does
    anybody know how to change the type library retrospectively? Presumably
    this would be done by finding where the CLSIDs are, and hacking them.

    Thanks,

    -------------------------
    Mark Alexander Bertenshaw
    Programmer/Analyst
    Prime Response
    Brentford
    UK


  8. #8
    Matthew Curland Guest

    Re: "Automation Error" when compiling application using private UserControl.

    The only way to hack the typelib right now is with the type library editor
    from my book. I haven't posted an integrated binary-compatibility editor
    yet, but this is just the normal editor with a bunch of commands turned off.
    See the readme for things you should/shouldn't do. You can do the resource
    replacement in the binary compatibility file by hand using VC++ (open as
    Resources). Also note that you might have to hand touch the _IID_* resource
    entries as well. I think VB might update these on a compile to match the
    entries in the typelib, but I'm not 100% sure. The format is described in
    chapter 15 of the book. -Matt



  9. #9
    Mark Alexander Bertenshaw Guest

    Re: "Automation Error" when compiling application using private UserControl.


    Matt -

    Thanks for replying. I will indeed look at the appropriate chapter (I'm only
    up to chpt 9 so far), and have a go at playing with the editor. Since I see
    no reason to change the interfaces of the two public classes (of which, only
    the UserDocument has any methods - a single event), then this should be easier.

    BTW Have you any explanation for why compiling with Binary Compatibility
    woud cause this "Automation Error"?

    Thanks,

    -------------------------
    Mark Alexander Bertenshaw
    Programmer/Analyst
    Prime Response
    Brentford
    UK

    "Matthew Curland" <mattcur@microsoft.com> wrote:
    >The only way to hack the typelib right now is with the type library editor
    >from my book. I haven't posted an integrated binary-compatibility editor
    >yet, but this is just the normal editor with a bunch of commands turned

    off.
    >See the readme for things you should/shouldn't do. You can do the resource
    >replacement in the binary compatibility file by hand using VC++ (open as
    >Resources). Also note that you might have to hand touch the _IID_* resource
    >entries as well. I think VB might update these on a compile to match the
    >entries in the typelib, but I'm not 100% sure. The format is described in
    >chapter 15 of the book. -Matt
    >
    >



  10. #10
    Mark Alexander Bertenshaw Guest

    Re: "Automation Error" when compiling application using private UserControl.

    Further information:

    After compiling with binary compatibility, if you open the Form or
    UserDocument, the IDE informs you that you are unable to load the control,
    and the UserControl is missing from the designers. Interestingly enough, if
    you go and change the interface, private OR public, of the UserControl,
    <before> opening the Form or UserDocument this problem doesn't happen at
    all.

    Also, I have subsequently managed to open and compile the entire project
    with Binary Compatibility in VB6SP3. Unfortunately, I don't want to
    distribute and VB 6 stuff to anybody, since a lot of the potential users are
    developers using VB5, so this isn't an option.

    --
    Mark Alexander Bertenshaw
    Programmer/Analyst
    PrimeResponse
    Brentford
    UK
    "Mark Alexander Bertenshaw" <mark.bertenshaw@virgin.net> wrote in message
    news:39d7ae9a@news.devx.com...
    > 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
    >
    >




Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center