OpcNetApi Group Subscription DataChangedEventHandler throws System.NullReferenceException|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
OpcNetApi Group Subscription DataChangedEventHandler throws System.NullReferenceException
Avatar
Chris Wong
New Member
Members
Forum Posts: 1
Member Since:
01/31/2018
sp_UserOfflineSmall Offline
1
02/02/2018 - 07:24
sp_Permalink sp_Print sp_EditHistory

I have a basic subscription and it works fine on my development computer. But for the life of me I am unable to deploy it to a server. When I run the application it throws an error on this specific line of code (highlighted in red):

Note: I have OPC Core Components Redistributable x64 3.0.107.24 installed.

groupState = new Opc.Da.SubscriptionState();

groupState.Name = "Group";

groupState.Active = true;

group = (Opc.Da.Subscription)opcServer.CreateSubscription(groupState);

group.DataChanged += new Opc.Da.DataChangedEventHandler(OnTransactionCompleted);

 

I get a System.NullReferenceException: Object reference not set to an instance of an object.

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()

 

The same exact .exe run on my dev computer works with no issues.

Has anyone seen something like this? I've been struggling with this for days. Thanks.

Avatar
Randy Armstrong
Admin
Forum Posts: 1451
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
2
02/02/2018 - 13:54
sp_Permalink sp_Print

This a common DCOM configuration issue.

With OPC COM the firewalls on the client machine must be opened to all the server to access the client process.

If there is a problem with DCOM configuration you get the '0x80040202' error.

Search for OPC and that error code to find resources. 

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 31
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1351
Posts: 4579