titanium-as / TitaniumAS.Opc.Client

Open source .NET client library for OPC DA
MIT License
193 stars 94 forks source link

Unable to cast COM object of type 'System.__ComObject' to interface type 'TitaniumAS.Opc.Client.Interop.Da.IOPCBrowse' #51

Open pisipisi opened 3 years ago

pisipisi commented 3 years ago

I'm trying to connect DA v2.0 and this give error below

System.InvalidCastException: 'Unable to cast COM object of type 'System.__ComObject' to interface type 'TitaniumAS.Opc.Client.Interop.Da.IOPCBrowse'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{39227004-A18F-4B57-8B0A-5235670F4468}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).' the OPC DA is on opcda://localhost/Server.1 Do I need to setup DCOM or something on this error?

pisipisi commented 3 years ago

After I change DCOM, got this error

2020/12/08 11:03:37:785 [WARN]  TitaniumAS.Opc.Client.Da.OpcDaServer - Cannot setup name of client.
=======================================================(inner most exception)===
 (1) System.NotImplementedException
================================================================================
Method        :  SetClientName
Type          :  TitaniumAS.Opc.Client.Interop.Common.IOPCCommon
Assembly      :  TitaniumAS.Opc.Client, Version=1.0.2.0, Culture=neutral, PublicKeyToken=null
Assembly Path :  C:\Users\thanh.nguyen\MyProject\DataPump\DataPumpService\DataPumpService\bin\Debug\TitaniumAS.Opc.Client.dll
Source        :  TitaniumAS.Opc.Client
Thread        :  9 ''
Helplink      :

Message:
"The method or operation is not implemented."

Stack Trace:
   at TitaniumAS.Opc.Client.Interop.Common.IOPCCommon.SetClientName(String szName)
   at TitaniumAS.Opc.Client.Common.Wrappers.OpcCommon.<>c__DisplayClass6.<set_ClientName>b__5()
   at TitaniumAS.Opc.Client.Common.ComWrapper.DoComCall(Object comObject, String methodName, Action comAction, Object[] arguments)
   at TitaniumAS.Opc.Client.Common.Wrappers.OpcCommon.set_ClientName(String value)
   at TitaniumAS.Opc.Client.Da.OpcDaServer.set_ClientName(String value)
   at TitaniumAS.Opc.Client.Da.OpcDaServer.Connect()
================================================================================

2020/12/08 11:03:37:810 [WARN]  TitaniumAS.Opc.Client.Da.Browsing.OpcDaBrowserAuto - Failed to browse address space using IOPCBrowse (OPC DA 3.x).
=======================================================(inner most exception)===
 (1) System.InvalidOperationException
================================================================================
Method        :  GetElements
Type          :  TitaniumAS.Opc.Client.Da.Browsing.OpcDaBrowser3
Assembly      :  TitaniumAS.Opc.Client, Version=1.0.2.0, Culture=neutral, PublicKeyToken=null
Assembly Path :  C:\Users\thanh.nguyen\MyProject\DataPump\DataPumpService\DataPumpService\bin\Debug\TitaniumAS.Opc.Client.dll
Source        :  TitaniumAS.Opc.Client
Thread        :  9 ''
Helplink      :

Message:
"Browser isn't attached to com object."

Stack Trace:
   at TitaniumAS.Opc.Client.Da.Browsing.OpcDaBrowser3.GetElements(String parentItemId, OpcDaElementFilter filter, OpcDaPropertiesQuery propertiesQuery)
   at TitaniumAS.Opc.Client.Da.Browsing.OpcDaBrowserAuto.GetElements(String parentItemId, OpcDaElementFilter filter, OpcDaPropertiesQuery propertiesQuery)
================================================================================

2020/12/08 11:03:37:824 [ERROR] TitaniumAS.Opc.Client.Common.ComWrapper - Error: System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
   at TitaniumAS.Opc.Client.Interop.Common.IEnumString.RemoteNext(Int32 celt, String[] rgelt, Int32& pceltFetched)
   at TitaniumAS.Opc.Client.Interop.Helpers.EnumHelpers.EnumerateAll(IEnumString enumerator, Int32 requestSize)
   at TitaniumAS.Opc.Client.Interop.Helpers.EnumHelpers.EnumareateAllAndRelease(IEnumString enumerator, Int32 requestSize)
   at TitaniumAS.Opc.Client.Da.Wrappers.OpcBrowseServerAddressSpace.<>c__DisplayClassa.<>c__DisplayClassc.<BrowseOpcItemIds>b__9()
   at TitaniumAS.Opc.Client.Common.ComWrapper.DoComCall[TResult](Object comObject, String methodName, Func`1 comAction, Object[] arguments) Method name: IEnumString::EnumareateAllAndRelease Object: 12625358
2020/12/08 11:03:37:830 [ERROR] TitaniumAS.Opc.Client.Common.ComWrapper - Error: System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
   at TitaniumAS.Opc.Client.Interop.Common.IEnumString.RemoteNext(Int32 celt, String[] rgelt, Int32& pceltFetched)
   at TitaniumAS.Opc.Client.Interop.Helpers.EnumHelpers.EnumerateAll(IEnumString enumerator, Int32 requestSize)
   at TitaniumAS.Opc.Client.Interop.Helpers.EnumHelpers.EnumareateAllAndRelease(IEnumString enumerator, Int32 requestSize)
   at TitaniumAS.Opc.Client.Da.Wrappers.OpcBrowseServerAddressSpace.<>c__DisplayClassa.<>c__DisplayClassc.<BrowseOpcItemIds>b__9()
   at TitaniumAS.Opc.Client.Common.ComWrapper.DoComCall[TResult](Object comObject, String methodName, Func`1 comAction, Object[] arguments)
   at TitaniumAS.Opc.Client.Da.Wrappers.OpcBrowseServerAddressSpace.<>c__DisplayClassa.<BrowseOpcItemIds>b__8()
   at TitaniumAS.Opc.Client.Common.ComWrapper.DoComCall[TResult](Object comObject, String methodName, Func`1 comAction, Object[] arguments) Method name: IOPCBrowseServerAddressSpace::BrowseOpcItemIDs Object: 47877643
2020/12/08 11:03:37:835 [WARN]  TitaniumAS.Opc.Client.Da.Browsing.OpcDaBrowserAuto - Failed to browse address space using IOPCBrowseServerAddressSpace (OPC DA 2.x).
=======================================================(inner most exception)===
 (1) System.Runtime.InteropServices.COMException
================================================================================
Method        :  RemoteNext
Type          :  TitaniumAS.Opc.Client.Interop.Common.IEnumString
Assembly      :  TitaniumAS.Opc.Client, Version=1.0.2.0, Culture=neutral, PublicKeyToken=null
Assembly Path :  C:\Users\thanh.nguyen\MyProject\DataPump\DataPumpService\DataPumpService\bin\Debug\TitaniumAS.Opc.Client.dll
Source        :  TitaniumAS.Opc.Client
Thread        :  9 ''
Helplink      :

Message:
"Error HRESULT E_FAIL has been returned from a call to a COM component."

Properties:
  COMException.ErrorCode = "-2147467259"

Stack Trace:
   at TitaniumAS.Opc.Client.Interop.Common.IEnumString.RemoteNext(Int32 celt, String[] rgelt, Int32& pceltFetched)
   at TitaniumAS.Opc.Client.Interop.Helpers.EnumHelpers.EnumerateAll(IEnumString enumerator, Int32 requestSize)
   at TitaniumAS.Opc.Client.Interop.Helpers.EnumHelpers.EnumareateAllAndRelease(IEnumString enumerator, Int32 requestSize)
   at TitaniumAS.Opc.Client.Da.Wrappers.OpcBrowseServerAddressSpace.<>c__DisplayClassa.<>c__DisplayClassc.<BrowseOpcItemIds>b__9()
   at TitaniumAS.Opc.Client.Common.ComWrapper.DoComCall[TResult](Object comObject, String methodName, Func`1 comAction, Object[] arguments)
   at TitaniumAS.Opc.Client.Da.Wrappers.OpcBrowseServerAddressSpace.<>c__DisplayClassa.<BrowseOpcItemIds>b__8()
   at TitaniumAS.Opc.Client.Common.ComWrapper.DoComCall[TResult](Object comObject, String methodName, Func`1 comAction, Object[] arguments)
   at TitaniumAS.Opc.Client.Da.Wrappers.OpcBrowseServerAddressSpace.BrowseOpcItemIds(OpcDaBrowseType browseFilterType, String filterCriteria, VarEnum dataTypeFilter, OpcDaAccessRights accessRightsFilter)
   at TitaniumAS.Opc.Client.Da.Browsing.OpcDaBrowser2.GetElementsImpl(String itemId, OpcDaElementFilter filter)
   at TitaniumAS.Opc.Client.Da.Browsing.OpcDaBrowser2.GetElements(String parentItemId, OpcDaElementFilter filter, OpcDaPropertiesQuery propertiesQuery)
   at TitaniumAS.Opc.Client.Da.Browsing.OpcDaBrowserAuto.GetElements(String parentItemId, OpcDaElementFilter filter, OpcDaPropertiesQuery propertiesQuery)
================================================================================

2020/12/08 11:03:37:850 [ERROR] TitaniumAS.Opc.Client.Common.ComWrapper - Error: System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
   at TitaniumAS.Opc.Client.Interop.Da.IOPCBrowseServerAddressSpace.ChangeBrowsePosition(OPCBROWSEDIRECTION dwBrowseDirection, String szName)
   at TitaniumAS.Opc.Client.Da.Wrappers.OpcBrowseServerAddressSpace.<>c__DisplayClass6.<ChangeBrowsePosition>b__5()
   at TitaniumAS.Opc.Client.Common.ComWrapper.DoComCall(Object comObject, String methodName, Action comAction, Object[] arguments) Method name: IOPCBrowseServerAddressSpace::ChangeBrowsePosition Object: 47877643
2020/12/08 11:03:37:855 [ERROR] TitaniumAS.Opc.Client.Common.ComWrapper - Error: System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
   at TitaniumAS.Opc.Client.Interop.Common.IEnumString.RemoteNext(Int32 celt, String[] rgelt, Int32& pceltFetched)
   at TitaniumAS.Opc.Client.Interop.Helpers.EnumHelpers.EnumerateAll(IEnumString enumerator, Int32 requestSize)
   at TitaniumAS.Opc.Client.Interop.Helpers.EnumHelpers.EnumareateAllAndRelease(IEnumString enumerator, Int32 requestSize)
   at TitaniumAS.Opc.Client.Da.Wrappers.OpcBrowseServerAddressSpace.<>c__DisplayClassa.<>c__DisplayClassc.<BrowseOpcItemIds>b__9()
   at TitaniumAS.Opc.Client.Common.ComWrapper.DoComCall[TResult](Object comObject, String methodName, Func`1 comAction, Object[] arguments) Method name: IEnumString::EnumareateAllAndRelease Object: 16826326
2020/12/08 11:03:37:862 [ERROR] TitaniumAS.Opc.Client.Common.ComWrapper - Error: System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
   at TitaniumAS.Opc.Client.Interop.Common.IEnumString.RemoteNext(Int32 celt, String[] rgelt, Int32& pceltFetched)
   at TitaniumAS.Opc.Client.Interop.Helpers.EnumHelpers.EnumerateAll(IEnumString enumerator, Int32 requestSize)
   at TitaniumAS.Opc.Client.Interop.Helpers.EnumHelpers.EnumareateAllAndRelease(IEnumString enumerator, Int32 requestSize)
   at TitaniumAS.Opc.Client.Da.Wrappers.OpcBrowseServerAddressSpace.<>c__DisplayClassa.<>c__DisplayClassc.<BrowseOpcItemIds>b__9()
   at TitaniumAS.Opc.Client.Common.ComWrapper.DoComCall[TResult](Object comObject, String methodName, Func`1 comAction, Object[] arguments)
   at TitaniumAS.Opc.Client.Da.Wrappers.OpcBrowseServerAddressSpace.<>c__DisplayClassa.<BrowseOpcItemIds>b__8()
   at TitaniumAS.Opc.Client.Common.ComWrapper.DoComCall[TResult](Object comObject, String methodName, Func`1 comAction, Object[] arguments) Method name: IOPCBrowseServerAddressSpace::BrowseOpcItemIDs Object: 47877643
2020/12/08 11:03:37:867 [WARN]  TitaniumAS.Opc.Client.Da.Browsing.OpcDaBrowserAuto - Failed to browse address space using IOPCBrowseServerAddressSpace (OPC DA 1.x).
=======================================================(inner most exception)===
 (1) System.Runtime.InteropServices.COMException
================================================================================
Method        :  RemoteNext
Type          :  TitaniumAS.Opc.Client.Interop.Common.IEnumString
Assembly      :  TitaniumAS.Opc.Client, Version=1.0.2.0, Culture=neutral, PublicKeyToken=null
Assembly Path :  C:\Users\thanh.nguyen\MyProject\DataPump\DataPumpService\DataPumpService\bin\Debug\TitaniumAS.Opc.Client.dll
Source        :  TitaniumAS.Opc.Client
Thread        :  9 ''
Helplink      :

Message:
"Error HRESULT E_FAIL has been returned from a call to a COM component."

Properties:
  COMException.ErrorCode = "-2147467259"

Stack Trace:
   at TitaniumAS.Opc.Client.Interop.Common.IEnumString.RemoteNext(Int32 celt, String[] rgelt, Int32& pceltFetched)
   at TitaniumAS.Opc.Client.Interop.Helpers.EnumHelpers.EnumerateAll(IEnumString enumerator, Int32 requestSize)
   at TitaniumAS.Opc.Client.Interop.Helpers.EnumHelpers.EnumareateAllAndRelease(IEnumString enumerator, Int32 requestSize)
   at TitaniumAS.Opc.Client.Da.Wrappers.OpcBrowseServerAddressSpace.<>c__DisplayClassa.<>c__DisplayClassc.<BrowseOpcItemIds>b__9()
   at TitaniumAS.Opc.Client.Common.ComWrapper.DoComCall[TResult](Object comObject, String methodName, Func`1 comAction, Object[] arguments)
   at TitaniumAS.Opc.Client.Da.Wrappers.OpcBrowseServerAddressSpace.<>c__DisplayClassa.<BrowseOpcItemIds>b__8()
   at TitaniumAS.Opc.Client.Common.ComWrapper.DoComCall[TResult](Object comObject, String methodName, Func`1 comAction, Object[] arguments)
   at TitaniumAS.Opc.Client.Da.Wrappers.OpcBrowseServerAddressSpace.BrowseOpcItemIds(OpcDaBrowseType browseFilterType, String filterCriteria, VarEnum dataTypeFilter, OpcDaAccessRights accessRightsFilter)
   at TitaniumAS.Opc.Client.Da.Browsing.OpcDaBrowser2.GetElementsImpl(String itemId, OpcDaElementFilter filter)
   at TitaniumAS.Opc.Client.Da.Browsing.OpcDaBrowser2.GetElements(String parentItemId, OpcDaElementFilter filter, OpcDaPropertiesQuery propertiesQuery)
   at TitaniumAS.Opc.Client.Da.Browsing.OpcDaBrowserAuto.GetElements(String parentItemId, OpcDaElementFilter filter, OpcDaPropertiesQuery propertiesQuery)