Items with no label
3335 Discussions

Set up simple C# Project with CS2017

SMath17
Beginner
1,592 Views

https://github.com/IntelRealSense/librealsense/tree/master/wrappers/csharp

 

Hi,

I have installed the SDK and trying to follow the readme at above link. I already have the Intel.Realsense.dll and realsense2.dll in C:\Program Files (x86)\Intel RealSense SDK 2.0\bin folder.

I am trying to run for example ...\librealsense\wrappers\csharp\cs-tutorial-1-depth but I don't know how.

Where is the .sln file? I am on a windows platform. thanks!

0 Kudos
3 Replies
MartyG
Honored Contributor III
887 Views

I will attempt to write the instructions in a more user-friendly way, starting from the point after Visual Studio 2017 has been installed. Please bear in mind that I have not actually performed this procedure myself, so I am interpreting the instructions, so I apologize in advance for any mistakes.

 

STEP ONE

 

Install the program called CMake if you have not done so already. Although it is not needed if you have installed the SDK from an executable file instead of building from source, it is needed for later steps in the process.

 

https://cmake.org/download/

 

STEP TWO

 

Install version 3.5 or newer of the .NET Framework if you have not done so already.

 

https://dotnet.microsoft.com/download/dotnet-framework-runtime/net472

 

STEP THREE

 

Open the CMake program and generate the 'realsense2.sln' solution with 'BUILD_CSHARP_BINDINGS' and 'BUILD_SHARED_LIBS' flags 

 

More information about this can be found on the Build Configurations Page of the SDK documentation.

 

https://github.com/IntelRealSense/librealsense/wiki/Build-Configuration

 

STEP FOUR

 

Go to the root directory of Librealsense.

 

STEP FIVE

 

From the Librealsense root directory, run the CMake program and enter the instructions listed below to generate the Visual Studio solution. When generated, the realsense2.sln file should appear in the build folder (which I believe is created as a sub-directory of the Librealsense root directory).

 

mkdir build

cd build

cmake .. -DBUILD_CSHARP_BINDINGS=ON -DBUILD_SHARED_LIBS=ON

 

STEP SIX

 

Open the realsense2.sln solution file in Visual Studio. If you look in the solution, the C# examples and library should be available there under Wrappers/csharp

 

I hope the above advice will be of use to you. Good luck!

SMath17
Beginner
887 Views

Thank you! I tried your steps and got further. I created a build folder and ran "cmake .. -DBUILD_CSHARP_BINDINGS=ON -DBUILD_SHARED_LIBS=ON".

This created a librealsense2.sln. I opened it, and built "cs-tutorial-1-depth" which was successful. When I ran it, I get the following error. Any ideas?

 

Exception.PNG

0 Kudos
MartyG
Honored Contributor III
887 Views

This error can result from having the Target Platform for building set to 'Any CPU'. For 32-bit it should be set to x86, and for 64-bit it should be set to x64.

 

https://github.com/IntelRealSense/librealsense/issues/2125

 

The user in the case linked to above said: "Generating solution with the following cmake command solved my issue."

 

cmake .. -DBUILD_CSHARP_BINDINGS=ON -DBUILD_SHARED_LIBS=ON -DCMAKE_GENERATOR_PLATFORM=x64

Reply