2

I'm trying to use a Intel RealSense camera in a c# project.
While the example code seams to run just fine.

My own project in a different folder raises an exception. Unable to load DLL
"realsense2:The specified module could not be found. (Exception from HRESULT:0x8007007E)."

I've now placed the realsense2.dll in lib folder and in debug folder. I think its a unmanaged dll and the other "Intel.RealSense.dll" seams a .net interface dll . I placed both in lib and in debug folders I tried referencing the Intel.realsense.dll (.net api wrapper) in both locations (debug folder and in lib folder), but to no success.

From Intel forums I noted that sometimes the error gets raised when the CPU model isn't correct, but I kept those the same as the sample. This must be some visual studio error (since the Intel example works). But I miss where it goes wrong.

Peter
  • 2,043
  • 1
  • 21
  • 45

2 Answers2

3

Step 1. Build the provided C++/C# samples using the instructions located in the main repo under /wrappers/csharp/readme.md

  • Generate the VS solution using cmake (run from librealsense root dir):

    • mkdir build
    • cd build
    • cmake .. -DBUILD_CSHARP_BINDINGS=ON -DBUILD_SHARED_LIBS=ON
  • The file realsense2.sln should be created in build folder, open the file with Visual Studio, C# examples and library will be available in the solution under Wrappers/csharp.

Both the native library and the .NET wrapper are built by default as part of the examples dependencies.

Step 2. Take a look at the working samples for reference. The default librealsense build on Windows is Debug/Win32 (For this config, built samples will be available at your_librealsense_dir/build/Debug)

In your C# project you need to have Intel.RealSense.dll added as a reference and copy realsense2.dll in your build directory ex: your_project_home/bin/x86/Debug

Prototype
  • 222
  • 1
  • 8
0

Note: Looking below, I think it's likely you have all these DLLs. Possibly you have a path issue. Check your EXE is running from the same folder the DLLs are in.

Here are the dependencies of realsense2.dll (x86) output by DUMPBIN:

These Windows ones:

KERNEL32.dll
USER32.dll
ole32.dll
OLEAUT32.dll
ADVAPI32.dll
SHLWAPI.dll
CFGMGR32.dll
SETUPAPI.dll
MF.dll
MFPlat.DLL
MFReadWrite.dll
WINUSB.DLL

And this VS 2017 one:

VCOMP140.DLL

Dependency Walker will tell you which ones you do or don't have.

Nick Westgate
  • 3,088
  • 2
  • 34
  • 41
  • my intelrealsense.dll (64bit system) shows a different dll list : Mscore.dll, kernel32, user32, advapi,shlwapi, version, oleaut32, urlmon. However, my main wondering is why it wont work in a lib folder construct, usually that works and its not that special. – Peter Jul 12 '18 at 11:31
  • When loading DLLs programmatically you can specify a path. But in .NET the easiest and most common way to automatically load assembles is if they're in the same directory. Otherwise you have to use something like the config file's [codebase](https://learn.microsoft.com/en-us/dotnet/framework/configure-apps/file-schema/runtime/codebase-element) element. – Nick Westgate Jul 13 '18 at 02:03
  • What i dont understand is that other projects i wrote used refered dll's in a lib folder as well, its no problem there,its only a problem when using realsense. – Peter Jul 13 '18 at 06:52
  • I think you'll find the reference has the copy flag set to true. That means the DLL gets copied to the output directory during the build. – Nick Westgate Jul 13 '18 at 07:14
  • changing the copy flag makes no difference, but they're verry keen on compiling their dll's yourself. (which i didnt) but makes me wonder if something is wrong there. different api bindings in debug and final dll's ..guessing – Peter Jul 13 '18 at 09:34
  • I noticed they use CMake, so it should Just Work (tm). Give it a go I suppose. – Nick Westgate Jul 13 '18 at 09:43