EDN Admin
Well-known member
Hi everyone,
Im writing a C#.net app that is controlling an OPC server.
Added a reference to the OPC server.
Have the interop wrapper classes generated.
Have the following code to instantiate the COM server and to attach to
the event:
Opc.URL url = new URL("opcda://localhost/KEPware.KEPServerEx.v4");
Opc.Da.Server daServer = new Opc.Da.Server(new OpcCom.Factory(), url);
daServer.Connect();
Everything compiles and runs OK.
Im able to execute methods and access properties of the COM object.
The event handler got called correctly too.
My problem is if I attach an event like below:
subscription.DataChanged +=new DataChangedEventHandler(subscription_DataChanged);
I will get a COMException during runtime.
System.Runtime.InteropServices.COMException (0x80040202): Exception from HRESULT: 0x80040202.
at OpcRcw.Comn.IConnectionPoint.Advise(Object pUnkSink, Int32& pdwCookie)
at OpcCom.ConnectionPoint.Advise(Object callback)
at OpcCom.Da.Subscription.Advise()
at OpcCom.Da.Subscription.add_DataChanged(DataChangedEventHandler value)
at Opc.Da.Subscription.add_DataChanged(DataChangedEventHandler value)
at BackFlush_POC.myOPC.connectOPC()
Any ideas? Please Help!!!
ThanX.
View the full article
Im writing a C#.net app that is controlling an OPC server.
Added a reference to the OPC server.
Have the interop wrapper classes generated.
Have the following code to instantiate the COM server and to attach to
the event:
Opc.URL url = new URL("opcda://localhost/KEPware.KEPServerEx.v4");
Opc.Da.Server daServer = new Opc.Da.Server(new OpcCom.Factory(), url);
daServer.Connect();
Everything compiles and runs OK.
Im able to execute methods and access properties of the COM object.
The event handler got called correctly too.
My problem is if I attach an event like below:
subscription.DataChanged +=new DataChangedEventHandler(subscription_DataChanged);
I will get a COMException during runtime.
System.Runtime.InteropServices.COMException (0x80040202): Exception from HRESULT: 0x80040202.
at OpcRcw.Comn.IConnectionPoint.Advise(Object pUnkSink, Int32& pdwCookie)
at OpcCom.ConnectionPoint.Advise(Object callback)
at OpcCom.Da.Subscription.Advise()
at OpcCom.Da.Subscription.add_DataChanged(DataChangedEventHandler value)
at Opc.Da.Subscription.add_DataChanged(DataChangedEventHandler value)
at BackFlush_POC.myOPC.connectOPC()
Any ideas? Please Help!!!
ThanX.
View the full article