Re: about casting
Hello!
I still have problems because we use only the concrete object of type
CSession in several mehods as you can see in the code below.
The first method is DBInitCommandTemplate. Here we just use the object
Session which was defined local in the old code but
in the new code we must use the Session that is stored in the concrete user
defined Handle_DS class.
As you can see in DBInitCommandTemplate method below we use the object
Session in this statement **below hr = sqlRole.Open(Session);**
So we don't use any method of Session here. The next method that cause
problem is method LoadProcedureRules.
The part that cause problem in this method is this statement **hr =
sqlItems.Open(*pSession, NULL, pDbPropSet);**
As you can see below we don't use any method for Session here either just
using the Session object as it is.
Have you any suggestion how to be able to use the Session object from the
user defined Handle_DS class. In the present code we have only one
thread from C# asp.net webb application into the COM object. Don't you think
it would be a good idea just to try your opaquq pointer solution that you
have suggested in one of your previous mail.
HRESULT CAlterObj::LoadProcedureRules(CSession *pSession, CDBPropSet
*pDbPropSet, BSTR ProductId, BSTR Revision, BSTR SubfileID)
{
CCommand<CAccessor<CDbProcedureRulesGet> > sqlItems;
hr = sqlItems.Open(*pSession, NULL, pDbPropSet);
}
HRESULT CAlterObj::DBInitCommandTemplate(some parameter here)
{
....
CCommand<CAccessor<CSetRole> > sqlRole;
//CSession Session; // old code
//CDataSource DS; // old code
//hr = DS.Open(); // old code
//hr = Session.Open(DS); // old code
hr = sqlRole.Open(Session);
hr = LoadProcedureRules(&Session,&dbPropSet,ProductID, Revision,
SubfileID);
....
}
//Tony
"Giovanni Dicanio" <giovanniDOTdicanio@REMOVEMEgmail.com> wrote in message
news:OuzHCRMWJHA.3688@TK2MSFTNGP02.phx.gbl...
"Giovanni Dicanio" <giovanniDOTdicanio@REMOVEMEgmail.com> ha scritto nel
messaggio news:%23u9SWbFWJHA.5456@TK2MSFTNGP05.phx.gbl...
Another option (as I wrote in my other post) would be to define a new COM
interface ISession to simply wrap the C++ concrete class CSession.
After some reflection, I believe that this is the most robust and reliable
thing to do. This is just the COM way to do; COM just exposes interfaces.
You should just define a new COM interface ISession, and implement it as a
wrapper to CSession C++ concrete class, and pass pointer to ISession, and
just call ISession methods.
I did some tests with a row "opaque" pointer to a concrete C++ class, they
worked in some cases, but I think that there could be other cases when
they don't work (for example, in case of different threading models
between the client and the COM object, etc.).
COM is a complex technology, and it is better to respect its rules than
trying "workarounds" (that could cause subtle bugs).
Giovanni