Article - CS238813

System.InvalidCastException error when connecting to OPC DA server using ThingWorx OPC DA Service

Modified: 06-Jun-2016   


Applies To

  • ThingWorx Platform 6.5 F000 to 7.1 F000

Description

  • The ThingWorx OPC DA service is unable to connect to the ThingWorx Server
  • ThingWorx server does not indicate that the ThingWorx OPC-DA Service is connected in the Connected Devices mashup.
  • After starting the ThingWorx OPC DA Service, the following error is returned in the DotNetSdk-<date>.log file:
[O: com.thingworx.opcda.OpcDaThing] Error connecting to OPC DA Server : System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type '“.’'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{39C13A4D-011E-11D0-9675-0020AFD8ADB3}' failed due to the following error: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).     at OPCDA.NET.OpcServer.™(Object srvObj)     at OPCDA.NET.OpcServer.—(String SrvName)     at OPCDA.NET.OpcServer.Connect(String SrvName)     at com.thingworx.opcda.OpcDaThing.Connect()
  • Error message as displayed in Notepad++ shows non-printable characters (in [square brackets]):
Error connecting to OPC DA Server : System.InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type '[STS][EOT]“.[PU2][EOT]’'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{39C13A4D-011E-11D0-9675-0020AFD8ADB3}' failed due to the following error: Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).     at OPCDA.NET.OpcServer.[SGCI][BS]™(Object srvObj)     at OPCDA.NET.OpcServer.—[EPA][BS](String SrvName)     at OPCDA.NET.OpcServer.Connect(String SrvName)     at com.thingworx.opcda.OpcDaThing.Connect()
This is a printer-friendly version of Article 238813 and may be out of date. For the latest version click CS238813