librealsense icon indicating copy to clipboard operation
librealsense copied to clipboard

CLR Windows Form Problem

Open tarekmuallim opened this issue 8 years ago • 11 comments

Required Info
Camera Model D400
Operating System & Version Windows 10 x64 (Visual Studio 2017)
Windows SDK version 10.0.16299.0
Platform toolset Visual Studio 2017 (v141)
SDK Version 2.10.4

I am trying to build a GUI using CLR Windows Form to get data from D415. But as I include librealsense2/rs.hpp I get this error: Error C1189 #error: is not supported when compiling with /clr or /clr:pure.

How can I fix this problem?

tarekmuallim avatar May 22 '18 09:05 tarekmuallim

[Realsense Customer Engineering Team Comment] @tarekmuallim I've tried to create Visual C++ Windows Desktop application and include the librealsense2/rs.hpp as attachment, I didn't see the effor you mentioned. Can you attach your project for me to check? thank you.

Attachment for above comment. capture

carypai avatar May 28 '18 09:05 carypai

@carypai @RealSense-Customer-Engineering Thank you for the replay. Actually, I am developing a C++/CLI application https://msdn.microsoft.com/en-us/library/hh875053.aspx Project1.zip

so I am using a CLR windows form. Attached you find a copy of the project. Thanks again.

tarekmuallim avatar May 29 '18 06:05 tarekmuallim

clr

tarekmuallim avatar May 29 '18 06:05 tarekmuallim

Project1.zip

tarekmuallim avatar May 29 '18 06:05 tarekmuallim

Hi @tarekmuallim I can confirm that what you are trying to do is correct and should work. rs_types.hpp seem to have couple of includes that has no place there. I'll create a pull-request and it will be published in 2.12 release. You have couple of options until then:

  1. Use the .NET wrapper assembly. You can consume our .NET wrapper from both C# and C++ CLI (and any other CLR language) If your end-goal is WinForms / WPF type GUI, using C# would probably make more sense.
  2. Use the C API (#include <librealsense2\rs.h>)
  3. Manually remove #include <mutex>, #include <condition_variable> and #include <atomic> from rs_types.hpp.

dorodnic avatar May 30 '18 08:05 dorodnic

Hi @dorodnic

Thank you for the reply. Right now I have to use C API.

I didn't find #include <mutex> in rs_types.hpp . I find #include <condition_variable> and #include <atomic> I also try to remove this two includes but still have error.

If the problem is in rs_types.hpp could you please send me a copy of the modified one?

Thanks again.

tarekmuallim avatar May 30 '18 10:05 tarekmuallim

The changes are not limited to just rs_types.hpp, but you can see what I did here: https://github.com/IntelRealSense/librealsense/pull/1794/files I double checked that the project you attached can be compiled with these changes.

dorodnic avatar May 30 '18 11:05 dorodnic

ok I see. Thank you for your help.

tarekmuallim avatar May 30 '18 13:05 tarekmuallim

[Realsense Customer Engineering Team Comment] @tarekmuallim The PR has been created also provided workaround to you, can the ticket be closed?

Ok Thank you.

tarekmuallim avatar Jun 01 '18 04:06 tarekmuallim