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:
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?
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