Professional OPC
Development Tools

logos

Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see links in upper right corner) in order to Post questions. You do not have to be a licensed user of our product.

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

Object Disposed Exception -> Unhandled

More
27 Feb 2022 15:23 #10658 by mpp
The try-catch is not handling the exception.
I can try to extract just the code that use your lib and prepare a sample csproj but it really is just a timer that read some variables.

Let me know if you need it.


Thanks

Please Log in or Create an account to join the conversation.

More
27 Feb 2022 14:04 #10657 by mpp
It is just a timer that check a variable every 10seconds.
If that variable assumes a certain value I write a value to that variable and then read a block of other variables.

This is the code I use to read a single variable:
DAVtq valueRead = null;
var rp = new DAReadParameters() { DataSource = (descriptor.ReadDevice ? DADataSource.Device : DADataSource.Cache) };
var sd = new ServerDescriptor() { MachineName = _connection.MachineName, ServerClass = _connection.ServerName };
var id = new DAItemDescriptor() { ItemId = _connection.PLC_ID + "." + descriptor.Key };
 
await Task.Run(() => valueRead = _client.ReadItem(sd, id, rp)).ConfigureAwait(false);

The approach is similar for multiple items read and for writing.
Should I put a try-catch in the lambda?

Thanks

Please Log in or Create an account to join the conversation.

More
27 Feb 2022 13:42 #10656 by support
Hello,

do you perhaps have a code/project (the smaller the better) that can reproduce this problem?

Best regards

Please Log in or Create an account to join the conversation.

More
27 Feb 2022 11:11 #10655 by mpp
Hi!

I'm having an issue with the DA client. This is what it is register as an unhandled exception on the windows event log:
Application: Statistics.PLCService.exe
CoreCLR Version: 6.0.21.52210
.NET Version: 6.0.0
Description: The process was terminated due to an unhandled exception.
Exception Info: System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'OpcLabs.EasyOpc.Implementation.NetApi.DataAccess.NetApiEasyDAClient'.
   at OpcLabs.EasyOpc.Implementation.NetApi.DataAccess.NetApiEasyDAClient.UnsubscribeMultipleItems(IEnumerable`1 handlesToUnsubscribe)
   at OpcLabs.EasyOpc.DataAccess.Implementation.ForwardingEasyDAClient.UnsubscribeMultipleItems(IEnumerable`1 handlesToUnsubscribe)
   at OpcLabs.EasyOpc.DataAccess.Implementation.ForwardingEasyDAClient.UnsubscribeMultipleItems(IEnumerable`1 handlesToUnsubscribe)
   at OpcLabs.EasyOpc.DataAccess.Implementation.DelegatingEasyDAClient.UnsubscribeMultipleItems(IEnumerable`1 handlesToUnsubscribe)
   at OpcLabs.EasyOpc.DataAccess.Implementation.HandleMappingEasyDAClient.UnsubscribeMultipleItems(IEnumerable`1 handlesToUnsubscribe)
   at OpcLabs.EasyOpc.DataAccess.Implementation.DelegatingEasyDAClient.DelegatedUnsubscribeMultipleItemsWithHandleMapping(IEnumerable`1 handlesToUnsubscribe)
   at OpcLabs.EasyOpc.DataAccess.Implementation.DelegatingEasyDAClient.<>c__DisplayClass13_0.<UnsubscribeMultipleItems>b__0()
   at OpcLabs.EasyOpc.DataAccess.Implementation.DelegatingEasyDAClient.<>c__DisplayClass109_0.<QueueBackEndAction>b__0()
   at OpcLabs.BaseLib.Threading.Extensions.FifoExecutionExtension.<>c__DisplayClass0_0.<QueueUserWorkItem>b__0(Object _)
   at OpcLabs.BaseLib.Threading.WorkItem.<>c.<.cctor>b__17_0(Object state)
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
   at OpcLabs.BaseLib.Threading.WorkItem.Execute()
   at OpcLabs.BaseLib.Threading.FifoExecution.ProcessQueuedItems(Object ignored)
   at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading.PortableThreadPool.WorkerThread.WorkerThreadStart()
   at System.Threading.Thread.StartCallback()

I'm using the last nuget package 5.62.1032. It's weird because I'm using the library quite extensively in the applications that are running together but only in this one I get this exception and I cannot understand where it is originated as I'm not subscribing to any opc variable.

Do you have any idea/suggestion on something I can do to fix this issue?

Thanks in advance

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.086 seconds