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
14 Mar 2022 10:48 #10738 by support
Oh, my fault, I somehow missed the fact that your post included the repro.
And, I tested it now, and it was very useful. I was able to reproduce the issue, and find and fix the root cause of it. Many thanks!

The fix will be in QuickOPC 2022.1, and the release "by the end of March" is still the plan.

Best regards

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

More
09 Mar 2022 09:23 #10718 by mpp
The code I shared in the previous post is all you need for a simple .net 6 console app.
You only need to create a project, copy that code in the program.cs file and add a reference to your nuget.

I let it run for a few seconds and it throws.
The following user(s) said Thank You: support

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

More
09 Mar 2022 07:24 #10717 by support
Hello.

The precise date is not yet set, but most likely by end of March.
If you needed, I can provide you with a pre-release build which already has the change described.

Note that, if you had a simple repro project, I would still welcome having it, due to reasons explained in my earlier post (the change made may not be the complete fix).

Best regfards

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

More
08 Mar 2022 07:57 #10712 by mpp
When is the next release scheduled for?

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

More
08 Mar 2022 07:14 #10710 by support
Hello,
thank you for letting me know. And the new approach you are taking would be the recommended one.

However, it seems to me that there was not wrong in principle with the way you were doing it before (except for efficiency concerns), so unless there was something else at play, it should not have thrown the exception. Hopefully, with the change I mentioned, that issue will be resolved as well.

Best regards

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

More
07 Mar 2022 15:45 #10709 by mpp
Hi I think that I found the source of the issue and now it is behaving like all the others client that I'm using in the application.

The difference was that the class that was performing the read/write was disposed after every read and the dispose was obviously disposing the
EasyDAClient
as well after calling the
UnsubscribeAllItems
method.

Now I changed the code and I'm not disposing the client anymore. It's running since a few hours with no issues.

This example will reproduce the error:
// See https://aka.ms/new-console-template for more information
using OpcLabs.EasyOpc;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;
 
Console.WriteLine("Hello, World!");
 
var timer = new System.Timers.Timer(1000)
{
    AutoReset = false,
    Enabled = true
};
 
timer.Elapsed += async (e, t) =>
{
    timer.Stop();
 
    try
    {
        var client = new EasyDAClient();
 
        client.SubscribeMultipleItems
            (
                new EasyDAItemSubscriptionArguments[]
                {
                    new EasyDAItemSubscriptionArguments
                    (
                        "",
                        "CoDeSys.OPC.DA",
                        "variable",
                        10000,
                        null
                    )
                }
            );
 
        var rp = new DAReadParameters() { DataSource = DADataSource.Device };
        var sd = new ServerDescriptor() { MachineName = "", ServerClass = "CoDeSys.OPC.DA" };
        var id = new DAItemDescriptor() { ItemId = "variable" };
        var result = client.ReadItem(sd, id, rp);
 
        Console.WriteLine(result.Value);
 
        client.UnsubscribeAllItems();
        client.Dispose();
    }
    catch (Exception ex)
    {
        Console.WriteLine(ex.ToString());
    }
    finally
    {
        timer.Start();
    }
};
 
Console.ReadLine();

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

More
01 Mar 2022 10:41 #10672 by mpp
Appreciate the fix and I'll prepare a sample project asap.
The only issue with it is that the error is not happening all the time but sporadically.

I have that piece of software managed in a way that it will be restarted automatically if it fails a "are you alive check".
In the last 2 days of work the program was restarted 9 times because of this issue.

I'll come back with the code when I'll be back in my office.


Thanks

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

More
01 Mar 2022 10:36 #10671 by support
Hello, and thank you.

Regarding the stack trace, it is like this:

You are right that it is "weird" that there are calls that have to do with unsubscribing, if you have not subscribed to anything. I have checked the code, and what is happening is that these calls are indeed made, but with an empty list of items to be unsubscribed. This is not really wrong, but sub-optimal. So, we have made a change (that will be effective with the next version release), and the calls will not be made at all, when the list is empty. So, in fact, may even fix the issue in this particular case.

But, there is a problem: There may be *other* situations that lead to the same effect (ObjectDisposedException). So we want to resolve that as well. But in order to so, I need a reproducible case of what you have, so that I can fully diagnose what is happening.

Best regards

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

More
01 Mar 2022 10:22 #10670 by mpp
Ok give me a couple of days because I'm at a customer and I can't prepare it now.
Can't you get any info from the stack trace?


Thanks

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

More
28 Feb 2022 19:00 #10668 by support
Hello,

I have made a simple project like that, but was unable to reproduce the issue.
Can you please create the repro ?

Regards

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

Moderators: support
Time to create page: 0.062 seconds