I have a project with a reference that may or may not exist. I have code that uses that reference and I'd like to compile it only if the assembly exists. I'm thinking something along the lines of:
#if ASSEMBLY_EXISTS
AssemblyClass.DoSomething();
#endif
I could put a #define at the top and comment/uncomment as needed, but I'd prefer if it could just somehow know if it's there without my manual intervention, which leads me to believe that #if won't work for this situation. Is there another way to conditionally compile based on whether an assembly exists?
ConditionalAttribute
but it still requires you to define the symbol yourself, personally I'd use the#if/#endif
because I'm not sure all compilers are required to abide by the attribute. – Jaquiss#define
d in a file are only valid for that file, you'd have to define them in every file in the project that uses the symbol. For this you can define global symbols in the properties which is a lot easier to maintain. – Jaquiss