Calling ATL COM Dll from Remote Machine 
Author Message
 Calling ATL COM Dll from Remote Machine

i am having an ATL Com Apartment Thread dll as a server.While creating the
dll. i have set the option ' Allow merging of Proxy/Stub Dll" as "Yes".
Now i would like to call this server dll from the client machine. i  am
using
CoCreateInstanceEx function to call the remote server dll. now i have two
doubts.
1. Do i need to register server dll in my client machine also..??
2. or do i need to create Proxy/Stub dll separately and if i register that
in my
   client, is that sufficient..??
Please help me..

Thanks in Advance
Thalaiappan



Mon, 29 Mar 2004 20:34:53 GMT  
 Calling ATL COM Dll from Remote Machine
You need a separate proxy/stub DLL to register it at the client. You
shouldn't have merged the proxy/stub code in the first place.

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> i am having an ATL Com Apartment Thread dll as a server.While creating the
> dll. i have set the option ' Allow merging of Proxy/Stub Dll" as "Yes".
> Now i would like to call this server dll from the client machine. i  am
> using
> CoCreateInstanceEx function to call the remote server dll. now i have two
> doubts.
> 1. Do i need to register server dll in my client machine also..??
> 2. or do i need to create Proxy/Stub dll separately and if i register that
> in my
>    client, is that sufficient..??
> Please help me..

> Thanks in Advance
> Thalaiappan



Wed, 31 Mar 2004 04:44:11 GMT  
 Calling ATL COM Dll from Remote Machine
Hii nckolov,
 thanks for your suggestion. i have some more doubts .
what should be the GUID of the proxy/stub dll. Is it the same
GUID of the main com server dll.  When i am trying to connect
the remote machine, i am getting error message "The Remote Procedure
Call Failed "(Err No : 800706BE) . MSDN says, this is because of not
calling CoInitialize() function. But i have called that function.

here is my code..

BOOL CImportServer::CreateInstance()
{
 HRESULT hr;
  MULTI_QI multi_qi;
 multi_qi.pIID   = &IID_IInterface;
 multi_qi.pItf = NULL;
 multi_qi.hr = 0;

  COSERVERINFO cosInfo;

 HKEY hKey = HKEY_LOCAL_MACHINE;
 LPCTSTR lpSubKey = "SOFTWARE\\EMSImport\\EMSImportClient";
 LPTSTR  lpszNode;
 lpszNode = "Server_Hostname";

 CString csServerName;

 CImportClientApp *pApp;
 pApp = ((CImportClientApp *)AfxGetApp());
 pApp->GetDataFromRegistry(lpszNode, &csServerName);

 ZeroMemory(&cosInfo, sizeof(cosInfo));
 cosInfo.pwszName = csServerName.AllocSysString();
  cosInfo.pAuthInfo = NULL;
 CLSID clsid;

//USES_CONVERSION;
//hr = CLSIDFromProgID(A2OLE("ImportServer.Interface.1"), &clsid);

 char szLocalComputer[50];
 unsigned long lComputerLen = 50;

 ::GetComputerName(szLocalComputer, &lComputerLen);

 CString csLocalComputer;
 csLocalComputer.Format("%s", szLocalComputer);

 hr = CoInitialize(NULL);
 if(FAILED(hr))
 {
  PopupErrorMessage(hr);
  return FALSE;
 }

 if ( csServerName.CompareNoCase(csLocalComputer) == 0 )
  hr = CoCreateInstanceEx(CLSID_Interface,NULL, CLSCTX_INPROC_SERVER,
&cosInfo, 1, &multi_qi);
 else
  hr = CoCreateInstanceEx(CLSID_Interface,NULL, CLSCTX_REMOTE_SERVER,
&cosInfo, 1, &multi_qi);
 if(FAILED(hr))
 {
  PopupErrorMessage(hr);
  return FALSE;
 }

 if(SUCCEEDED(hr))
    {
      hr = multi_qi.hr ;
      if (SUCCEEDED(hr))
      {
  m_pInterface = (IInterface *) multi_qi.pItf ;
  m_pImportServer = m_pInterface;
   }
 }
 else
 {
  PopupErrorMessage(hr);
  return FALSE;
 }

 return TRUE;

Quote:
}

////////////////////////////////////////////////////////////////////////////
////

i have build the proxy/stub dll. But if i register that dll, i am getting
error number
"80040154"  ..   really i don't understand what went wrong..?? can you help
me..

thals

Quote:
> You need a separate proxy/stub DLL to register it at the client. You
> shouldn't have merged the proxy/stub code in the first place.

> --
> =====================================
> Alexander Nickolov
> Microsoft MVP [VC], MCSD

> MVP VC FAQ: http://www.mvps.org/vcfaq
> =====================================



> > i am having an ATL Com Apartment Thread dll as a server.While creating
the
> > dll. i have set the option ' Allow merging of Proxy/Stub Dll" as "Yes".
> > Now i would like to call this server dll from the client machine. i  am
> > using
> > CoCreateInstanceEx function to call the remote server dll. now i have
two
> > doubts.
> > 1. Do i need to register server dll in my client machine also..??
> > 2. or do i need to create Proxy/Stub dll separately and if i register
that
> > in my
> >    client, is that sufficient..??
> > Please help me..

> > Thanks in Advance
> > Thalaiappan



Wed, 31 Mar 2004 22:25:24 GMT  
 Calling ATL COM Dll from Remote Machine
Have you configured your DLL on the remote machine with DCOMCnfg?
(Have you registered it there at least?) You have to create an AppID for
it, because its self-registration code doesn't do that. After you manually
create an AppID for the DLL on the remote machine, you can successfully
configure it with DCOM. Read "Professional DCOM Programming" by
Dr Richard Grimes, Wrox Press for details on how to create the AppID.
(I may add a FAQ article on the subject too...)

--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD

MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================


Quote:
> Hii nckolov,
>  thanks for your suggestion. i have some more doubts .
> what should be the GUID of the proxy/stub dll. Is it the same
> GUID of the main com server dll.  When i am trying to connect
> the remote machine, i am getting error message "The Remote Procedure
> Call Failed "(Err No : 800706BE) . MSDN says, this is because of not
> calling CoInitialize() function. But i have called that function.

> here is my code..

> BOOL CImportServer::CreateInstance()
> {
>  HRESULT hr;
>   MULTI_QI multi_qi;
>  multi_qi.pIID   = &IID_IInterface;
>  multi_qi.pItf = NULL;
>  multi_qi.hr = 0;

>   COSERVERINFO cosInfo;

>  HKEY hKey = HKEY_LOCAL_MACHINE;
>  LPCTSTR lpSubKey = "SOFTWARE\\EMSImport\\EMSImportClient";
>  LPTSTR  lpszNode;
>  lpszNode = "Server_Hostname";

>  CString csServerName;

>  CImportClientApp *pApp;
>  pApp = ((CImportClientApp *)AfxGetApp());
>  pApp->GetDataFromRegistry(lpszNode, &csServerName);

>  ZeroMemory(&cosInfo, sizeof(cosInfo));
>  cosInfo.pwszName = csServerName.AllocSysString();
>   cosInfo.pAuthInfo = NULL;
>  CLSID clsid;

> //USES_CONVERSION;
> //hr = CLSIDFromProgID(A2OLE("ImportServer.Interface.1"), &clsid);

>  char szLocalComputer[50];
>  unsigned long lComputerLen = 50;

>  ::GetComputerName(szLocalComputer, &lComputerLen);

>  CString csLocalComputer;
>  csLocalComputer.Format("%s", szLocalComputer);

>  hr = CoInitialize(NULL);
>  if(FAILED(hr))
>  {
>   PopupErrorMessage(hr);
>   return FALSE;
>  }

>  if ( csServerName.CompareNoCase(csLocalComputer) == 0 )
>   hr = CoCreateInstanceEx(CLSID_Interface,NULL, CLSCTX_INPROC_SERVER,
> &cosInfo, 1, &multi_qi);
>  else
>   hr = CoCreateInstanceEx(CLSID_Interface,NULL, CLSCTX_REMOTE_SERVER,
> &cosInfo, 1, &multi_qi);
>  if(FAILED(hr))
>  {
>   PopupErrorMessage(hr);
>   return FALSE;
>  }

>  if(SUCCEEDED(hr))
>     {
>       hr = multi_qi.hr ;
>       if (SUCCEEDED(hr))
>       {
>   m_pInterface = (IInterface *) multi_qi.pItf ;
>   m_pImportServer = m_pInterface;
>    }
>  }
>  else
>  {
>   PopupErrorMessage(hr);
>   return FALSE;
>  }

>  return TRUE;
> }

////////////////////////////////////////////////////////////////////////////

- Show quoted text -

Quote:
> ////

> i have build the proxy/stub dll. But if i register that dll, i am getting
> error number
> "80040154"  ..   really i don't understand what went wrong..?? can you
help
> me..

> thals


> > You need a separate proxy/stub DLL to register it at the client. You
> > shouldn't have merged the proxy/stub code in the first place.

> > --
> > =====================================
> > Alexander Nickolov
> > Microsoft MVP [VC], MCSD

> > MVP VC FAQ: http://www.mvps.org/vcfaq
> > =====================================



> > > i am having an ATL Com Apartment Thread dll as a server.While creating
> the
> > > dll. i have set the option ' Allow merging of Proxy/Stub Dll" as
"Yes".
> > > Now i would like to call this server dll from the client machine. i
am
> > > using
> > > CoCreateInstanceEx function to call the remote server dll. now i have
> two
> > > doubts.
> > > 1. Do i need to register server dll in my client machine also..??
> > > 2. or do i need to create Proxy/Stub dll separately and if i register
> that
> > > in my
> > >    client, is that sufficient..??
> > > Please help me..

> > > Thanks in Advance
> > > Thalaiappan



Sat, 03 Apr 2004 03:05:21 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Problem calling COM object on remote machine

2. ATL COM - Passing ATL COM classes through another ATL COM class in the same app

3. Deploying COM server in remote machine!

4. how to call function in a DLL from ATL COM method

5. Calling an ATL COM Dll from C program

6. how to call function in a DLL from ATL COM method

7. ATL COM object hangs on user32.dll MessageBoxA() call

8. ATL COM object hangs on user32.dll MessageBoxA() call

9. call a VB COM dll thru a C++ COM dll from a C program

10. call a VB COM dll thru a C++ COM dll from a C program

11. Register DLL on remote NT machine?

12. remote debugging - multple copies of msvcrt.dll on my machine

 

 
Powered by phpBB® Forum Software