COM Exception calling Disconnect on Opc.Da.Server object|Classic OPC: DA, A&E, HDA, XML-DA, etc.|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
COM Exception calling Disconnect on Opc.Da.Server object
Avatar
Lester Temple
New Member
Members
Forum Posts: 2
Member Since:
12/18/2020
sp_UserOfflineSmall Offline
1
02/11/2021 - 14:30
sp_Permalink sp_Print

We have a C# OPC DA Client component, that we are attempting to upgrade to the current OPC libraries

Has anyone encountered this problem, or have any insight ??

I get this exception when I call the Disconnect() method on the Opc.Da.Server object:

System.InvalidCastException
HResult=0x80004002
Message=Unable to cast COM object of type 'System.__ComObject' to interface type 'OpcRcw.Comn.IConnectionPoint'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B196B286-BAB4-101A-B69C-00AA00341D07}' failed due to the following error: The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD)).
Source=mscorlib
StackTrace:
at System.StubHelpers.StubHelpers.GetCOMIPFromRCW(Object objSrc, IntPtr pCPCMD, IntPtr& ppTarget, Boolean& pfNeedsRelease)
at OpcRcw.Comn.IConnectionPoint.Unadvise(Int32 dwCookie)
at OpcCom.ConnectionPoint.Unadvise()
at OpcCom.ConnectionPoint.Dispose()
at OpcCom.Server.Dispose(Boolean disposing)
at OpcCom.Da.Server.Dispose(Boolean disposing)
at OpcCom.Server.Dispose()
at Opc.Server.Disconnect()
at Savigent.Libraries.OpcSupport.OpcClient.StopOpcServer() in C:\Dev\Source\PlatformLibraries\OpcSupport\Savigent.Libraries.OpcSupport\OPC Client\OPCClientAgent.cs:line 545

Thanks

Avatar
Randy Armstrong
Admin
Forum Posts: 1564
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
02/11/2021 - 18:19
sp_Permalink sp_Print

COM objects created in a single threaded apartment can only be called from that thread.

See:

https://flylib.com/books/en/2......75.1.69/1/

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online: David Puffer
Guest(s) 53
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1435
Posts: 4855