jmmorato / openddsharp

OpenDDS wrapper for .NET languages
http://www.openddsharp.com
GNU Lesser General Public License v3.0
53 stars 12 forks source link

System.AccessViolationException on listener set. #137

Closed MarcoRoccagliSigma closed 1 year ago

MarcoRoccagliSigma commented 1 year ago

Hi, I'm attemping to set a datareader listener to inbuilt topic "DCPSParticipant" and while executing the setlistener method, i receive the AccessViolationException. Here there is the snippet code that i'm trying to use:

static void Main(string[] args) { Ace.Init();

        DomainParticipantFactory dpf = ParticipantService.Instance.GetDomainParticipantFactory("-DCPSConfigFile", "rtps.ini");
        DomainParticipant participant = dpf.CreateParticipant(42);
        if (participant == null)
        {
            throw new Exception("Could not create the participant");
        }

        // Include your program here

        TestExample.TestTypeSupport testsupport= new TestExample.TestTypeSupport();
        testsupport.RegisterType(participant, testsupport.GetTypeName());

        Topic topic = participant.CreateTopic("TestTopic", testsupport.GetTypeName());

        Publisher pub= participant.CreatePublisher();

        DataWriter dw = pub.CreateDataWriter(topic);
        TestExample.TestDataWriter tdw = new(dw);

        DataReader participantdr = participant.GetBuiltinSubscriber().LookupDataReader("DCPSParticipant");
        **participantdr.SetListener(new CustomDCPSParticipantListener());**

        while (true)
        {
            tdw.Write(new() { Key = 0, Message="Test" });
            System.Threading.Thread.Sleep(1000);
        }

        participant.DeleteContainedEntities();
        dpf.DeleteParticipant(participant);
        ParticipantService.Instance.Shutdown();

        Ace.Fini();
    }

Of course CustomDCPSParticipantListener extends from DataReaderListener. Any clue for this?

Thanks

jmmorato commented 1 year ago

I couldn't reproduce it with the latest 0.8.22323.102-beta version.

What version are you using?

MarcoRoccagliSigma commented 1 year ago

Hi using the 0.8.22127.96 that comes with standard .NET templates. Should i update to latest version?

MarcoRoccagliSigma commented 1 year ago

Just to inform that i updated at same version that you suggested and the problem persists.

jmmorato commented 1 year ago

Same for me but in the other way around, downgraded to your version and still couldn't reproduce the issue.

Could you share your full projects files please?

MarcoRoccagliSigma commented 1 year ago

That's a WeTransfer link because of size (around 140MB)

https://we.tl/t-kRT5P9MGXz

For your info, i'm using VS2022 forcing to compile to x64 (but i have the same issue forcing in x86)

jmmorato commented 1 year ago

I reproduced (only happens in windows) and fixed in #138, if all tests are successfully I will create a new beta version after merging.

PD:

That's a WeTransfer link because of size (around 140MB)

Next time remove bin, obj and .vs folders before zipping ;)

MarcoRoccagliSigma commented 1 year ago

Thanks i will try and let you know ASAP

jmmorato commented 1 year ago

Version 0.8.22349.103-beta has been published

MarcoRoccagliSigma commented 1 year ago

Tried this version and seems to work correctly. Thanks for fixing.