Re: DCOM to DCOM call fails with 80040200

From: Alexander Nickolov (agnickolov_at_mvps.org)
Date: 09/16/04


Date: Thu, 16 Sep 2004 10:26:43 -0700

So is it that AtlAdvise returns this eror? Or you called
IConnectionPoint::Advise manually? In any other situation
the code would mean something different - depending on
the interface being called.

-- 
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnickolov@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Sanjay Dattatri" <sdattatri@vsnl.com> wrote in message 
news:2c3fbb74.0409160305.657445ab@posting.google.com...
>I thought this error was returned from AtlAdvise(). MSDN says
> +++++++++++++++++++++++++++
> CONNECT_E_NOCONNECTION Error
> For the CONNECT_E_NOCONNECTION error, verify that there is a
> connection point entry for the globally unique identifier (GUID) of
> the event interface in the connection point map, as in the following
> example:
> Sample Code
> BEGIN_CONNECTION_POINT_MAP(CMySource)
>   CONNECTION_POINT_ENTRY(DIID__MySourceEvents)
> END_CONNECTION_POINT_MAP()
> ++++++++++++++++++++++++++++++++++++++++++++
> The function works properly if it is called from an application.
> Fails only when called from another DCOM!
>
> "Alexander Nickolov" <agnickolov@mvps.org> wrote in message 
> news:<eBA7riumEHA.3756@TK2MSFTNGP09.phx.gbl>...
>> Debug your code to see why you return that error. It's
>> your code that returns it after all... Note this is an
>> interface-specific error code, your assumption about
>> its meaning is likely wrong.
>>
>> -- 
>> =====================================
>> Alexander Nickolov
>> Microsoft MVP [VC], MCSD
>> email: agnickolov@mvps.org
>> MVP VC FAQ: http://www.mvps.org/vcfaq
>> =====================================
>> "Sanjay Dattatri" <sdattatri@vsnl.com> wrote in message
>> news:2c3fbb74.0409141940.379a8798@posting.google.com...
>> > Hi,
>> > I have the following problem.  I have some DCOM classes which work
>> > fine when they are called from a VC++ MDI client or a ASP, but dont
>> > work when called from other DCOM classes.
>> >
>> > For example I have a compression class that works perfectly when
>> > called from ASP, VC++ client, but not from another DCOM [the code for
>> > both are given below].  In the latter case it returns with 80040200
>> > [NOCONNECTION]].
>> > The funny thing is that if I create a CString object in the caller
>> > function AFTER the DCOM call is made, then the DCOM to DCOM call
>> > works!!!
>> > I am sure I have missed something fundamental here.  Can someone throw
>> > any light, please?
>> >
>> > Thanks in advance.
>> > Sanjay
>> >
>> > -----------------------------------------------------------------------------------------------
>> > // Compress.h : Declaration of the CCompress
>> >
>> > #ifndef __COMPRESS_H_
>> > #define __COMPRESS_H_
>> >
>> > #include "resource.h"       // main symbols
>> >
>> > /////////////////////////////////////////////////////////////////////////////
>> > // CCompress
>> > class ATL_NO_VTABLE CCompress :
>> > public CComObjectRootEx<CComSingleThreadModel>,
>> > public CComCoClass<CCompress, &CLSID_Compress>,
>> > public IDispatchImpl<ICompress, &IID_ICompress, &LIBID_SPSCOMUTILLib>
>> > {
>> > public:
>> > CCompress()
>> > {
>> > }
>> >
>> > DECLARE_REGISTRY_RESOURCEID(IDR_COMPRESS)
>> >
>> > DECLARE_PROTECT_FINAL_CONSTRUCT()
>> >
>> > BEGIN_COM_MAP(CCompress)
>> > COM_INTERFACE_ENTRY(ICompress)
>> > COM_INTERFACE_ENTRY(IDispatch)
>> > END_COM_MAP()
>> >
>> >
>> > // ICompress
>> > public:
>> > STDMETHOD(ReduceXml)(/*[in]*/BSTR bstrInput, /*[in, out]*/VARIANT*
>> > varOutput, /*[in, out]*/ VARIANT* varErrData, /*[
>> >
>> > out, retval]*/short* bSuccess);
>> > STDMETHOD(ODecompress)(/*[in]*/VARIANT *vtInData, /*[in,
>> > out]*/VARIANT* varRetData, /*[out, retval]*/short* bSuccess
>> >
>> > );
>> > STDMETHOD(OCompress)(/*[in]*/BSTR bstrInput, /*[in, out]*/VARIANT*
>> > varRetData, /*[out, retval]*/short* bSuccess);
>> > };
>> >
>> > #endif //__COMPRESS_H_
>> > -------------------------------------------------------------------------------------------------------
>> >
>> > Calling function [This is a member in another DCOM]
>> > +++++++++++++++++++++++++++++++++++++++++++++++++++
>> > STDMETHODIMP CDCOMSchStoreXML::UpdateXML(BSTR bstrSessionId, BSTR
>> > schObjId,
>> >
>> >
>> > BSTR baseLineId, BSTR strXML,
>> >
>> >
>> > BSTR timestmp)
>> > {
>> > HRESULT hResult = S_FALSE;
>> > _ConnectionPtr pConn = NULL;
>> > _RecordsetPtr pRecordSet = NULL;
>> >
>> > FieldsPtr pFields = NULL;
>> > FieldPtr pField = NULL;
>> > _bstr_t strQueryStr(L"");
>> >
>> > _bstr_t bstrSchObjId(schObjId);
>> > _bstr_t bstrBaseLineId(baseLineId);
>> > _bstr_t bstrXML(strXML);
>> > _bstr_t bstrTimeStmp(timestmp);
>> >
>> > // Compress the Xml using SpsComUtil's interface to ZLib
>> > SPSCOMUTIL::ICompress* pCompress = NULL;
>> > CLSID clsId;
>> > VARIANT varCompressedXml;
>> > short bSuccess = 0;
>> >
>> > // 1. Get the Class Id for the Interface to query
>> > CString strClsId(_T("SpsComUtil.Compress"));
>> > BSTR bstrClsId = NULL;
>> >
>> > try
>> > {
>> > bstrClsId = strClsId.AllocSysString();
>> > ComUtils::Test_HResult(CLSIDFromProgID((LPCOLESTR)bstrClsId,
>> > &clsId));
>> >
>> > // 2. Create an instance of the interface
>> > hResult = m_spObjectContext->CreateInstance(clsId,
>> >
>> >
>> > (__uuidof(SPSCOMUTIL::ICompress)),
>> >
>> >
>> > (void**)&pCompress);
>> > ComUtils::Test_HResult(hResult);
>> >
>> >
>> > // 3. Call the method
>> > ComUtils::Test_HResult(hResult = pCompress->OCompress(strXML,
>> > &varCompressedXml, &bSuccess));
>> > // varCompressedXml contains Safe Array so can be used directly to
>> > AppendChunk
>> >
>> > strQueryStr = "SELECT xmlData, xmlTimeStmp FROM scheduleObj WHERE "
>> >                  "schObjId = '" + bstrSchObjId + "' AND "
>> >                  "baselineId = '" + bstrBaseLineId + "' " ;
>> >
>> > _bstr_t bstrTempConnString =
>> > DBUtils::GetDecryptedConnectionString(bstrSessionId);
>> >
>> > if (S_OK == (hResult = pConn.CreateInstance(__uuidof(Connection))) )
>> > {
>> > if (S_OK == (hResult = pConn->Open(bstrTempConnString, "", "", -1))
>> > )
>> > {
>> > if (S_OK == (hResult =
>> > pRecordSet.CreateInstance(__uuidof(Recordset))) )
>> > {
>> > if (S_OK == (hResult = pRecordSet->Open(_variant_t(strQueryStr),
>> > _variant_t((IDispatch *)
>> >
>> > pConn,true), adOpenKeyset,
>> > adLockOptimistic, adCmdText))
>> >
>> > )
>> > {
>> >
>> > if(pRecordSet->GetRecordCount() != 1) // No record found!!
>> > hResult = S_FALSE;
>> > else
>> > {
>> > pFields = pRecordSet->Fields;
>> > pField = pFields->Item[SCHOBJTAB_XMLDATA];
>> > //hResult = pField->AppendChunk(_variant_t(varCompressedXml));
>> > pField->Value = varCompressedXml;
>> > if (S_OK == hResult)
>> > {
>> > pField = pFields->Item[SCHOBJTAB_XMLTIMESTAMP];
>> > pField->Value = _variant_t(bstrTimeStmp);
>> >
>> > hResult = pRecordSet->Update();
>> > }
>> > }
>> >
>> > pRecordSet->Close();
>> > }
>> >
>> > pConn->Close();
>> > }
>> > }
>> > }
>> > }
>> > catch(_com_error &e)
>> > {
>> > WORD wCode = e.WCode();
>> > hResult = _com_error::WCodeToHRESULT(wCode);
>> > }
>> > catch(...)
>> > {
>> > hResult = E_UNEXPECTED;
>> > }
>> > CString str; str.Format("hResult is %x", hResult); // REMOVE these two
>> > lines and the call to compress
>> >    // will FAIL!!!
>> > LogUtils::WriteTrace("SPSCOMRET", str);
>> > ::SysFreeString(bstrClsId);
>> >
>> > #ifndef NO_MTS
>> > if (S_OK == hResult)
>> > m_spObjectContext->SetComplete();
>> > else
>> > m_spObjectContext->SetAbort();
>> > #endif
>> >
>> > return hResult;
>> > } 


Relevant Pages

  • Re: DCOM to DCOM call fails with 80040200
    ... > work when called from other DCOM classes. ... > STDMETHODIMP CDCOMSchStoreXML::UpdateXML(BSTR bstrSessionId, BSTR ... > HRESULT hResult = S_FALSE; ... > // Compress the Xml using SpsComUtil's interface to ZLib ...
    (microsoft.public.vc.atl)
  • Re: Cluster IP address resource could not create required TCP/IP
    ... Is there a specific component under DCOM that should be active? ... compare from node A to node B but is there a specific entry that I should ... >> Cluster IP Address resource 'xxx IP' could not create the required TCP/IP ... >> to create new IP interface, ...
    (microsoft.public.windows.server.clustering)
  • Re: COM question
    ... marshaller and so it can't marshall this type automatically. ... This posting is provided "AS IS" with no warranties, and confers no rights. ... marshaling that interface or something? ... of the OS that would affect this (it's a DCOM build, ...
    (microsoft.public.windowsce.platbuilder)
  • COM question
    ... I'm doing some work with a COM object which is running on Windows CE devices ... and which is used, via DCOM, from other devices, PCs, generally, on the ... returns an IEnumString interface pointer to the caller and that doesn't ... would affect this (it's a DCOM build, ...
    (microsoft.public.windowsce.platbuilder)
  • Re: CoCreateInstance from a DLL for DCOM server
    ... Microsoft MVP, MCSD ... > I have a DCOM server which runs as a service. ... > In this DLL i have a global variable g_IInterface. ... > Will CoCreateInstance get called for every process?? ...
    (microsoft.public.vc.atl)