4

After I compiled my C# in my new Windows 8 64-Bit machine, I started to get the following error while getting list of available servers in my OPC client application.

"OpcNetApi.Com Unable to cast COM object of type 'System.__ComObject' to interface type 'OpcRcw.Comn.IOPCServerList2'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{9DD0B56C-AD9E-43EE-8305-487F3188BF7A}' failed due to the following error: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))."

What could be the reason?

Demir
  • 1,787
  • 1
  • 29
  • 42

4 Answers4

11

Quoted from the OPC.NET readme :

The .NET COM interop assemblies are built against the 32-bit versions of the proxy/stubs. This means that any .NET application running on x64 systems must be compiled and run as a 32-bit application

Camille G.
  • 3,058
  • 1
  • 25
  • 41
7

Hi: To solve this problem install OPC .NET API OPC .NET API 2.00 Redistributables 105.1 and then install OPC Core Components Redistributable (x64) 105.1. With this you can connect to OPC Server runing in 32 bits fom client running on 64 bit.

Olivier De Meulder
  • 2,493
  • 3
  • 25
  • 30
user2480745
  • 111
  • 1
  • 2
  • 1
    Thanks for this answer. In my case, I tried installing OPC Core Components 3.0.106 (latest) and it did not fix my issue. I did several things and I'm not sure which specific thing fixed it, but I deleted "OpcEnum.exe" from syswow64, installed Core Components 2.0.2.30, and also installed OpcEnum as a service using installutil (but that was before the re-install). Try installing multiple versions of Core Components if you're having this issue. – Jared Beach Mar 01 '17 at 20:38
  • 1
    After more testing, I believe that deleting out the old dlls and opcenum before installing core components is what fixes this. – Jared Beach Mar 08 '17 at 20:47
  • Building in VS for Any CPU and installing latest x64 OPC core components as suggested here fixed my OPC connection issues. – Mr. Blonde May 15 '17 at 08:47
2

And don't foget, that Redistributables (OPC .NET API OPC .NET API 2.00 Redistributables, OPC Core Components Redistributables) and libraries (OpcNetApi.dll, OpcNetApi.Com.dll, OpcNetApi.Xml.dll...) referenced in your project must be the same versions.

undejavue
  • 99
  • 6
-1

i think the only problem is you are trying to connect to remote machine with different user and password you must create your current user in remote machine same as local machine username and password then you must configure on remote machine "component services"->Console root->Component Services->Computers->Dcom config->OpcEnum setting and give access to this user in Properties -> Security my problem solved by this way good luck

  • indeed this just make remote server accessible and if you want to access to opc servers on remote machine you must do dcom configure for that opc server – kaydream Jan 31 '19 at 11:46
  • 1
    this is a 5 year old question which already has an accepted answer. I don't believe that your answer adds any value to this question. – BlueWater86 Jan 31 '19 at 11:51