Community
cancel
Showing results for 
Search instead for 
Did you mean: 
jb455
Valued Contributor II
79 Views

C#: Referencing Local DLLs

Hi,

I'm getting to the deployment stage with my project, and I'm having problems referencing the RealSense DLLs properly.

Up to now, I've been copying the DLLs from the RSSDK folder to my project folder each time I've updated the SDK and referencing them from there. When I've been testing on devices I have control of, I've made sure the SDK/Runtime is always up to date so that it matches the DLLs I have packaged with my application. However, I've noticed that if the referenced DLLs are from a different SDK/Runtime version (eg, if I've included the latest DLLs in my installer but the user has an older version installed), the camera refuses to start when I call it form the app (or more precisely: PXCMSenseManager.CreateInstance() always returns null).

So, my thought was that I should instead reference the local DLLs that the user already has installed so it's always matched to their SDK/Runtime version. The devguide (C:/Program Files (x86)/Intel/RSSDK/doc/PDF/sdkdevguide.pdf, section 3.3.2) makes it sound easy but unfortunately the Visual Studio 2015 GUI doesn't allow environment variables in reference paths. Some Googling ensued and eventually I found out that you have to edit the .csproj file manually and change the libpxcclr.cs HintPath to $(RSSDK_DIR)bin\win32\libpxcclr.cs.dll. (Sidenote to Intel: maybe update the devguide with this info?) Now when I look at the reference in my project it points to the correct path in Program Files, but when I test the application it still doesn't work. My current state is this:

  • If I set Copy Local to False in the libpxcclr.cs reference, I would expect my application to go to the RSSDK folder and run the DLL from there (where libpxccpp2c also exists). However, it appears .NET doesn't actually do this for some reason; it only looks for DLLs in the application folder so I get a libpxcclr.cs not found error.
  • Conversely, if I set Copy Local to True, it copies libpxcclr.cs from the RSSDK folder which is great, but it doesn't know that it also needs libpxccpp2c in the same folder so I get a libpxccpp2c not found error. I thought I would be able to counteract this by adding a reference to libpxccpp2c in the same way as the other one so that copies over too, but when I try to add it I get a message complaining that it is not a valid assembly or COM component.

 The only way I can think of getting round this is to manually (in the code) copy the dlls to the application folder each time my app runs, which doesn't sound ideal and can't be the 'official' way of doing this. Does anyone know of a better way?

Thanks!

James

0 Kudos
1 Reply
Bryan_B_Intel1
Employee
79 Views

Hi James,

It sounds like you have your reference to the managed DLL working OK. To ensure the unmanaged RealSense DLL gets copied from the SDK installation folder to your project's output folder automatically, open your project's properties, select Build Events, and add this to your Post-build event command line:

if "$(Platform)" == "x86" ( copy /y "$(RSSDK_DIR)\bin\win32\libpxccpp2c.dll" "$(TargetDir)" ) else ( copy /y "$(RSSDK_DIR)\bin\x64\libpxccpp2c.dll" "$(TargetDir)" )

This should grab the correct DLL depending on your  target platform (x86 or x64). 

Hope this helps, Bryan

Reply