Search code examples
c++comopcdcom

IOPCShutdown::Advise Failed : error 80040202


I broke my head while looking for the cause of this error (4 days)

  • I have an OPC DA server running in a remote machine.
  • The OPC DA client is located in another machine.

in the client implementation I create an external instance via CoCreateInstanceEx()

HRESULT result = ::CoCreateInstanceEx(clsid, NULL, clsctx, sinptr, 1, &mqi);
PRINT_COMERRORIF(result, "CoCreateInstanceEx failed");

and it works fine and I get a pointer to the remote OPC server (mqi.pItf)

the problem comes when I call the advise() function of IConnectionPoint interface

I specify that I found the connection point and I return a pointer to the IOPCShutdown interface (_MY_shutdown) before calling the advise function

result = server_object->QueryInterface(IID_IConnectionPointContainer 
(void**)&connection_point_container);
PRINT_COMERRORIF(result, CTXID(this) "No IConnectionPointContainer interface");

result = connection_point_container->FindConnectionPoint(IID_IOPCShutdown, &_MY_shutdown);
PRINT_COMERRORIF(result, CTXID(this) "No IOPCShutdown connection point found");

result = _MY_shutdown->Advise(_MY_shutdown_callback, &_MY_shutdown_cookie); // HERE IS THE ISSUE 
PRINT_COMERRORIF(result, CTXID(this) "IOPCShutdown::Advise Failed");

and I got this error:

IOPCShutdown::Advise Failed : error 80040202

I've checked the DCOM Setting for Discovery of Remote OPC Servers configuration and I did everything as described but no way ;(

Here is my configuration:

Server side

 - OPC DA Server installed and running

 - local user account is created

 - DCOM settings are configured as required

 - Policy settings are configured as well

Client side

 - OPC DA client interface installed.

 - local user accounts are created on the both Nodes. Accounts have the same 
   name and passwords like on the server.

firewall is disabled in both server/client.


Solution

  • It works when I change the authentification level of my OPC DA server in DCOM Config from "Connect" to "None", I don't know why but it works ^^