One of the modes of my program uses Microsoft Kinect but the user may never decide use that mode. I want to make it so the libraries for that functionality are only looked for and loaded if he uses that mode of the program as opposed to it throwing an error because the kinect end-user runtime library (or whatever it’s called) is not installed when the program is first opened. Is that possible in C#? If so, how is that done?
2
We do this all the time on our software. All you need to do is make sure all of the references to that library are in a different class that is only ever called when the option is enabled. I think you also need to have your classes in a separate .cs file so that the using
statements are also isolated. (I don’t know for certain since we keep all our classes in separate files by policy.)
public class Application {
public void InitOptions {
if(optionWithThirdPartyDependency) {
OptionalFunctionality.InitFeature();
}
}
}
In a different .cs file….
using ThirdPartyLibrary
public class OptionalFunctionality {
public static void InitFeature() {
<init the feature using ThirdPartyLibrary>
}
}