2
votes

I'm partly developing opc client application using opc.net api and I have some trouble connecting remote opc server. Below please see the code I wrote to connect to opc server.

Opc. URL url = new Opc. URL ( "opcda://network-pc/some-opc-server" );
Opc.Da. Server server = null ;
OpcCom. Factory fact = new OpcCom. Factory ();
server = new Opc.Da. Server (fact, null );
server.Connect(url, new Opc. ConnectData ( new System.Net. NetworkCredential ()));

After executing this code I am getting error: System.Runtime.InteropServices.ExternalException: CoCreateInstanceEx: Access is denied.

In addition, both computers are in the same local network, and I can connect to opc server from my computer using third party opc clients.

Is there anybody who faced with this kind of issue? Thanks in advance.

2

2 Answers

3
votes

This may not be your C# source code issue. This could be DCOM permission issue. You have to configure DCOM permission based on your OPC Server guidance for client application.

Following documents for general reference for OPC and DCOM settings

http://www.sytech.com/download/OPC_and_DCOM.pdf

http://www.automation.com/pdf_articles/Troubleshooting_OPC_and_DCOM.pdf

0
votes

In addition to the answer from Zin Min, make sure that you are on the same domain. As cross domain connections are not possible using OPC-DA, without tunnelling of some kind.