rticommunity / rticonnextdds-connector-cs

RTI Connector for Connext DDS is a lightweight technology that enables DDS data to be accessed with C#.
https://rticommunity.github.io/rticonnextdds-connector-cs
Other
9 stars 7 forks source link

SEHException: Error creating connector #4

Open emrcnort opened 4 years ago

emrcnort commented 4 years ago

I cloned the connector repository using the git clone https://github.com/rticommunity/rticonnextdds-connector-cs --recursive command.

I got an error when trying to run thebuild.ps1 command through powershell. Thanks to the help I received through RTI Community, I learned that I should do it as follows: I was able to compile the connector api by running the dotnet build -f netstandard1.1 command in the src/Connector directory.

After building process, RTI.Connext.Connector.dll was imported into Unity (Assets/Plugins folder) and C:\rticonnextdds-connector-cs\rticonnextdds-connector\lib\x64Win64VS2013 added to environment PATH.

But still I get this error in Unity3D:

SEHException: Error creating connector
RTI.Connext.Connector.Interface.Connector..ctor (System.String configName, System.String configFile) (at C:/rticonnextdds-connector-cs/src/Connector/Interface/Connector.cs:29)

The code block causing the error:

public class MotionControl : MonoBehaviour {

    string configPath = "/Scenes/USER_QOS_PROFILES.xml";
    string configName = "MyParticipantLibrary::SubscriptionParticipant";

  void Start()
 {
    try
     {
        Connector connector = new Connector(configName, configPath);
         RTI.Connext.Connector.Input reader = connector.GetInput(readerName);

    }
    catch (Exception e)
    {
      Debug.LogError($"Cannot create connector: {e}");
      return;
    }

}

What am I doing wrong?

pleonex commented 4 years ago

Packaging things for Unity with native libraries is a bit tricky. I did a demo time ago with C# Connector and Unity 3D for the Oculus Go. You may want to try to follow the steps from my demo ignoring anything VR related: https://github.com/pleonex/dds-unity

Unfortunately I don't have still the device so I can't test it again. I don't know if it will work with the latest version of Unity, hopefully that will be the case.

emrcnort commented 4 years ago

Thank you for your support. But the connector compilation method you use in your project does not work for me. I have already tried this. When I try to compile build.ps1 script via powershell i get this error:

MSBUILD : error MSB1001: Unknown switch.
Switch: /warnaserror

For switch syntax, type "MSBuild /help"
An error occurred when executing task 'Build-API'.
Error: One or more errors occurred.
MSBuild: Process returned an error (exit code 1).

For this, I tried compiling the connector with the method I mentioned above, but this time I get another error.

pleonex commented 4 years ago

I think that's because the version of Cake is quite old and it doesn't work with the latest version of MSBuild. It should work after upgrading Cake by changing the file tools/packages.config so it uses the latest version 0.37.0.

emrcnort commented 4 years ago

Upgrading Cake solved the build problem and the build was successful. After build process I copied connector/src/Connector/bin/Debug/net35/*.dll into Assets/Plugins.
But I'm still getting the same error:

SEHException: Error creating connector
RTI.Connext.Connector.Interface.Connector..ctor (System.String configName, System.String configFile) (at C:/rticonnextdds-connector-cs/src/Connector/Interface/Connector.cs:29)
kPatch commented 4 years ago

@pleonex thank you for the suggestion on Cake 0.37.0 ! I was initially downgrading my MSBuild Tools.
Btw, I believe I can test your Oculus Go demo in the coming weeks. I'll keep you posted.

If you get a chance, let me know if you encountered the following error when deploying your Oculus project: https://github.com/rticommunity/rticonnextdds-connector-cs/issues/3

kPatch commented 4 years ago

@emrcnort can you double check the you're referencing the actual path of the config file? I encountered the same error. On the editor something like the following works: const string configPath = "Assets/Resources/ShapeExample.xml";

But, after building the project for other platforms ( e.g. Android, iPhone or Unity Web Player) that path is invalid. Depending on your platform, you can use something like the following to reference the StreamingAssets folder.

string configPath = Application.streamingAssetsPath + "/ShapeExample.xml"; Or, you can use Application.dataPath to create an absolute reference to the path.

emrcnort commented 4 years ago

@kPatch I tried all the methods you suggested, but I keep getting the same error. (I am trying to access the config file from within the Unity editor). Could this be due to a version mismatch between Unity and DDS? Here are the versions I use:

alexcamposruiz commented 4 years ago

The Connector library has dependencies on additional native libraries (nddscore.dll, nddsc.dll). Make sure the path points to the correct directory in (connector)/lib/...

pleonex commented 4 years ago

If I remember correctly this error usually means that the native library found a problem and it couldn't create the main entity. Usually in my case was because the XML was not found (invalid path, invalid permissions, missing dependencies, etc). I remember that at least from the Oculus Go I could get more logging and I remember seeing the actual error messages from the native libraries, including the one from the loader with "missing lib X". Not sure on other platforms.

I recommend you to try to find / enable more logging from Unity, hopefully you will see the native warnings / errors. Also, may could try to "print / read" the XML from your application with the same path you are passing to Connector, something like File.ReadAllText(), to make sure from the app works.

emrcnort commented 4 years ago

@alexcamposruiz PATH contains all of the following directories:

C:\rticonnextdds-connector-cs\rticonnextdds-connector\lib\x64Win64VS2013
C:\Program Files\rti_connext_dds-6.0.1\lib\x64Win64VS2015
C:\Program Files\rti_connext_dds-6.0.1\bin

As I understand it, RTI C # Connector only works with Visual Studio 2013 or 2010 versions. But the DDLs (nddscore.dll, nddsc.dll) you mentioned are located in the C:\Program Files\rti_connext_dds-6.0.1\lib\x64Win64VS2015directory. This directory contains two folders: x64Win64VS2015 and x64Win64VS2017. But I am using VS2013 version for C# Connector and VS2013 is not here. Could the source of the error be this version mismatch?

emrcnort commented 4 years ago

@pleonex Thank you for your help. I will try your recommendations. Hope they help me find the solution

EDIT : Unity editor successfully readed the XML configuration file with the File.ReadAllText()function. I think the problem is all about the DLL.

EDIT2 : I deleted and reloaded the DLLs and noticed that: The connector is successfully created during the first launch when Unity is closed and reopened, and no errors occur. But I get the SEHException: Error creating connector error when Playmode is launched a second time and many times. I tried the Dispose ()method for this, but I think this was not the right choice.

pleonex commented 4 years ago

If it's working the first time it's a bit weird. It could be that the "Play Mode" is reading the native libraries from a different directory? Does it work when you compile the application and run outside the unity studio?

Also note that this C# Connector API may not work with the latest Connector native libraries. Make sure to use the one from the commit linked in the submodule of this repository, which I think it corresponds to the libraries of Connector for 5.3.1 (this could be your issue @kPatch). At that time, the connector library was compiled statically so it shouldn't need nddscore.dll and other library, just rtiddsconnector.dll.

emrcnort commented 4 years ago

@pleonex Sorry for the late comeback. I tried C # Connector on another project other than Unity and it worked without errors. Could the problem be related to the version of Unity I am using?

prothen commented 3 years ago

I have the same problem with receiving a null pointer from the native libraries. Is there a way to debug this further without *.pdbs of the native binaries?