🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #2685

Re: CoInitialize issues

#2685
From: Mike Collins
Date: Thu, 01 Feb 2007 14:30
142 lines
5885 bytes
Remy, thanks a hundred fold, you reply was very useful

I've just given it a quick scan but the points you raised are very valid - 
i'll give it my full attention when i get back.

The problem that i'm having is that i cannot reproduce the error - we have 
done hundreds of sales and thus installations without issue.  It has only 
been reported by a handfull of people.  To add to this problem, all the 
uninstallation funcitonality and live update functionality WAS only 
accessible from the help - so if the dialog fails, as it has, we knacked. 
There is no, proactical was to remove the software.  This was obviously a 
design flaw by myself and has been re-addressed - there are now other ways 
to access the said fucntionality.

But because of this, i can't send out updates to try and test to see if 
anything resolves the problem.  I did strip out the Help dialog and place it 
in a stand alone applicaiton that mimiced exactly, what was going on and 
sent this to our clients, however theis executed without issue and displaye 
dthe dialog correctly.

I have not tracked down a UK customer who is allowing me access to there 
laptop tomorrow so i should be able to provide you with a beter 
explaintaiton and locate the point of failour.

I had thought that it might be possible that some of the OLE / COM 
underlying services might not be fully initialised at such an early point in 
the startup of the system.



"Remy Lebeau (TeamB)" <no.spam@no.spam.com> wrote in message 
news:45c154b4$1@newsgroups.borland.com...
>
> "Mike Collins" <its@TheBottomOfThePost.com> wrote in message
> news:45c145d9$1@newsgroups.borland.com...
>
>> we have now started to have reports, from the US, that the help
>> dialog is failing to be displayed and the error message returned
>> seems to relate to the CoInitialize call failing.
>
> Please be more specific.  What exactly is happening?  What is the
> actual error code being returned?  Is it actually being reported when
> you call CoInitialize() yourself, or when the dialog is being created?
>
>>       catch (const Exception &exception)
>>       {
>>          // ************* This seems to be the error message that is
>> displayed **************
>
> Given the code you have shown, the error has to be coming from the
> dialog itself, since that is the only place a VCL exception can be
> getting thrown from.  It would be helpful to know exactly WHICH line
> is throwing the exception, though.
>
> Probably the dialog is making its own call to CoInitialize/Ex()
> (directly or indirectly) and then failing because CoInitialize() was
> previously called with a different threading model specified.
>
>> The problem seems to be in the initial call to CoInitialize, and the
> error
>> message that our users are seeing is that displayed from the last
> catch
>> statement (Exception &exception).
>
> What is the actual error message?
>
>> I know this is a bit general
>
> Too general.
>
>> should i sit in a loop calling CoInitialize until i get a success.
>
> Absolutely not.
>
>> If is possible that the necessary services will not have been fully
>> started at that point?
>
> No, because you already one one call to CoInitialize() succeeding
> before the error ocurs.
>
>
> Try this code instead:
>
>    if( SUCCEEDED(CoInitialize(NULL)) )
>    {
>        try
>        {
>            THelpOptDlg *HelpOptDlg = NULL;
>
>            try
>            {
>                HelpOptDlg = new THelpOptDlg(NULL);
>            }
>            catch (...)
>            {
>                GinaStub->WlxMsgBox(DISPLAY_HELP_DLG_CREATE_ERROR_MSG,
> MB_OK | MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST);
>            }
>
>            if( HelpOptDlg )
>            {
>                try
>                {
>                    try
>                    {
>                        iModalRst = HelpOptDlg->ShowModal();
>                    }
>                    __finally
>                    {
>                        delete HelpOptDlg;
>                    }
>                }
>                catch (const Exception &)
>                {
>
> GinaStub->WlxMsgBox(DISPLAY_HELP_DLG_SHOW_ERROR_MSG, MB_OK |
> MB_ICONERROR | MB_TASKMODAL | MB_TOPMOST);
>                }
>            }
>        }
>        catch (const Exception &e)
>        {
>            AnsiString szExpMsg;
>
> szExpMsg.sprintf(GinaStub->RtnSz(KID_SAFE_GENERAL_EXCEPTION_MSG),
> e.Message.c_str());
>            GinaStub->WlxMsgBox(szExpMsg, MB_OK | MB_ICONERROR |
> MB_TASKMODAL | MB_TOPMOST);
>        }
>
>        // Must be called once the form with the corrisponding OLE
> container is destroyed
>        CoUninitialize();
>    }
>    else
>        GinaStub->WlxMsgBox(DISPLAY_HELP_OLE_ERROR_MSG, MB_OK |
> MB_ICONWARNING | MB_TASKMODAL | MB_TOPMOST);
>
>
> Gambit
>
> 
Technical Details
Message-ID: <45c1f95f$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <45c145d9$1@newsgroups.borland.com> <45c154b4$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,6927f106572d30a6
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Mike Collins" <its@TheBottomOfThePost.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <45c145d9$1@newsgroups.borland.com> <45c154b4$1@newsgroups.borland.com>
Subject: Re: CoInitialize issues
Date: Thu, 1 Feb 2007 14:30:52 -0000
Lines: 144
Organization: SDA Ltd
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.3790.2826
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.2826
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 84.13.44.38
Message-ID: <45c1f95f$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1170340191 84.13.44.38 (1 Feb 2007 06:29:51 -0800)
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail