🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.database.multi-tier
Article #410

CreateObject and CoCreateInstance problem

#410
From: Hans-Joachim Herholz
Date: Mon, 24 Jun 2002 13:08
49 lines
2280 bytes
Hi!

I'm using a self written component in BCB 5 that does something like the new
TSharedConnection in BCB6.

Now I have a little problem on the server side.

If I use the following syntax everything is ok:



   class TRDMServer : public TCRemoteDataModule {
     ....
    Variant pIRDMModule, ...
    ...
  };

 STDMETHODIMP TRDMServerImpl::GetRDMInterface(LPDISPATCH* RetVal)
{
         IRDMModuleName *lpp;
         CoCreateInstance(CLSID_RDMModuleName, NULL, CLSCTX_INPROC_SERVER,
IID_IRDMModuleName, reinterpret_cast<void**>(&lpp));
         m_DataModule->pIRDMModuleName=lpp;
         lpp->Init(Value1, Value2);
      *RetVal=m_DataModule->pIRDMModule;
}

Changing the code to

 STDMETHODIMP TRDMServerImpl::GetRDMInterface(LPDISPATCH* RetVal)
{

m_DataModule->pIRDMModule=m_DataModule->pIRDMModule.CreateObject("Name");
         m_DataModule->pIRDMModule.OleFunction("Init", Value1, Value2);
      *RetVal=m_DataModule->pIRDMModule;
}

which is much simpler, everthing just works fine until the application is
closed.

The second code leads to a substantial crash with access violations.

What can cause the application to crash when using the second way?



Thank you for any help.

Hans-Joachim
Technical Details
Message-ID: <3d1719e0$1_2@dnews>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!news.tele.dk!small.news.tele.dk!212.43.194.69!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!news.uni-stuttgart.de!nntp.cs.uni-magdeburg.de!PeerFeed.KWeb.on.ca!dnews

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: fcd2b,1d575db6fbb1a938,start
X-Google-Attributes: gidfcd2b,public
X-Google-ArrivalTime: 2002-06-24 06:17:17 PST
Reply-To: "Hans-Joachim Herholz" <Herholz@t-online.de>
From: "Hans-Joachim Herholz" <Herholz@t-online.de>
Newsgroups: borland.public.cppbuilder.database.multi-tier
Subject: CreateObject and CoCreateInstance problem
Date: Mon, 24 Jun 2002 15:08:25 +0200
Lines: 52
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2600.0000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000
NNTP-Posting-Host: 217.80.159.70
Message-ID: <3d1719e0$1_2@dnews>
X-Trace: dnews 1024924128 217.80.159.70 (24 Jun 2002 06:08:48 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-01!supernews.com!news.tele.dk!small.news.tele.dk!212.43.194.69!fr.clara.net!heighliner.fr.clara.net!newsfeed01.sul.t-online.de!t-online.de!news.belwue.de!news.uni-stuttgart.de!nntp.cs.uni-magdeburg.de!PeerFeed.KWeb.on.ca!dnews