Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail to run rcldotnet_examples on win10 OS,throw System.ArgumentNullException #119

Open
cqulpj opened this issue Sep 17, 2023 · 2 comments

Comments

@cqulpj
Copy link

cqulpj commented Sep 17, 2023

my PC system is win10, the ros2 version is foxy, visual studio 2019, .net 3.1/6/7, first, every steps of build was ok, but when I try run the examples, it throw Exceptions, the error messages as follow:

PS C:\opt\ros_dotnet_ws> .\install\local_setup.ps1
PS C:\opt\ros_dotnet_ws> ros2 run rcldotnet_examples rcldotnet_talker

Unhandled Exception: System.TypeInitializationException: The type initializer for 'ROS2.RCLdotnetDelegates' threw an exception. ---> System.ArgumentNullException: Value cannot be null.
Parameter name: ptr
at System.Runtime.InteropServices.Marshal.GetDelegateForFunctionPointer(IntPtr ptr, Type t)
at ROS2.RCLdotnetDelegates..cctor() in C:\opt\ros_dotnet_ws\src\ros2_dotnet\ros2_dotnet\rcldotnet\RCLdotnet.cs:line 451
--- End of inner exception stack trace ---
at ROS2.RCLdotnet.Init() in C:\opt\ros_dotnet_ws\src\ros2_dotnet\ros2_dotnet\rcldotnet\RCLdotnet.cs:line 1399
at ConsoleApplication.RCLDotnetTalker.Main(String[] args) in C:\opt\ros_dotnet_ws\src\ros2_dotnet\ros2_dotnet\rcldotnet_examples\RCLDotnetTalker.cs:line 12

who can give me some suggestions, well regards.

@SiebeVerhoeven
Copy link

SiebeVerhoeven commented Nov 13, 2023

I've not particularly solved the problem, but I found something.

the rcldotnet_native.dll file is made in the _dllLoadUtils this file has a few ten's of functions. For me the file misses 2 functions that are needed in the RCLDotnet.cs. so I commented them out and now it works fine for me. only thing i'm concerned about is that I now miss these 2 functions. I guess these are not needed for me. but maybe someone can explain what these functions are for:

// IntPtr native_rcl_take_response_ptr = // _dllLoadUtils.GetProcAddress(nativeLibrary, "native_rcl_take_response"); // RCLdotnetDelegates.native_rcl_take_response = // (NativeRCLTakeResponseType)Marshal.GetDelegateForFunctionPointer( // native_rcl_take_response_ptr, typeof(NativeRCLTakeResponseType));

// IntPtr native_rcl_write_to_qos_profile_handle_ptr = // _dllLoadUtils.GetProcAddress(nativeLibrary, "native_rcl_write_to_qos_profile_handle"); // RCLdotnetDelegates.native_rcl_write_to_qos_profile_handle = // (NativeRCLWriteToQosProfileHandleType)Marshal.GetDelegateForFunctionPointer( // native_rcl_write_to_qos_profile_handle_ptr, typeof(NativeRCLWriteToQosProfileHandleType));

@hoffmann-stefan
Copy link
Member

@cqulpj, @SiebeVerhoeven: Sorry for the late reply, currently my "spare" time I can allocate for this project is used to get the open PRs done. I tried to setup ros2_dotnet on windows once, but didn't have time to continue yet.

@SiebeVerhoeven did you try a cleen rebuild? Those functions should be defined in the c part of the library, so not sure how they would be missing for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants