Testing the presence of a reference
-
We're developing an application (.net 2.0 / C#) that interacts with Office and other external applications. So all needed references are added to Visual Studio's "References" and then used ("using x.y.z") in our sources. This works fine but what if someone (an enduser) doesn't have say MS Project installed? The sources won't compile, crying that "The type or namespace 'MSProject' does not exist ... (are you missing an assembly reference?)". Is there any possibility to make a (prior) test if a reference is available or not? Something like a try/catch surrounding the "using" statement? In fact we would like to test if MS Project (or another application) is installed and if not simply don't provide the functionality. I searched on MSDN, Google Groups, etc but did not find something useful... Thank you very much for your help!
-
We're developing an application (.net 2.0 / C#) that interacts with Office and other external applications. So all needed references are added to Visual Studio's "References" and then used ("using x.y.z") in our sources. This works fine but what if someone (an enduser) doesn't have say MS Project installed? The sources won't compile, crying that "The type or namespace 'MSProject' does not exist ... (are you missing an assembly reference?)". Is there any possibility to make a (prior) test if a reference is available or not? Something like a try/catch surrounding the "using" statement? In fact we would like to test if MS Project (or another application) is installed and if not simply don't provide the functionality. I searched on MSDN, Google Groups, etc but did not find something useful... Thank you very much for your help!
Maercu wrote:
what if someone (an enduser) doesn't have say MS Project installed? The sources won't compile,
Why would an "end user" be compiling? :confused:
Maercu wrote:
In fact we would like to test if MS Project (or another application) is installed and if not simply don't provide the functionality. I searched on MSDN, Google Groups, etc but did not find something useful...
Take a clean machine and save the registry. Install MS Project and save the registry to another file. Do a DIFF on the two files.
led mike
-
We're developing an application (.net 2.0 / C#) that interacts with Office and other external applications. So all needed references are added to Visual Studio's "References" and then used ("using x.y.z") in our sources. This works fine but what if someone (an enduser) doesn't have say MS Project installed? The sources won't compile, crying that "The type or namespace 'MSProject' does not exist ... (are you missing an assembly reference?)". Is there any possibility to make a (prior) test if a reference is available or not? Something like a try/catch surrounding the "using" statement? In fact we would like to test if MS Project (or another application) is installed and if not simply don't provide the functionality. I searched on MSDN, Google Groups, etc but did not find something useful... Thank you very much for your help!
What happens when you compile evertything with the references working and then put it on a machine without the office programs? It should throw an exception when you try to create an object based on the references. Examine the description for that and you should be able to then do try->catch on startup to tell what is installed.
Assert(this);
-
We're developing an application (.net 2.0 / C#) that interacts with Office and other external applications. So all needed references are added to Visual Studio's "References" and then used ("using x.y.z") in our sources. This works fine but what if someone (an enduser) doesn't have say MS Project installed? The sources won't compile, crying that "The type or namespace 'MSProject' does not exist ... (are you missing an assembly reference?)". Is there any possibility to make a (prior) test if a reference is available or not? Something like a try/catch surrounding the "using" statement? In fact we would like to test if MS Project (or another application) is installed and if not simply don't provide the functionality. I searched on MSDN, Google Groups, etc but did not find something useful... Thank you very much for your help!
OK thanks for your help so far. Another idea: Would it be a better idea to integrate/import the DLL(s) during run-time? So rather than including them via Visual Studio's "References" to include them directly in the classes that need them? I imagine that this way compiling would always be fine and that the statement could be put inside a try/catch structure so catching the situation when a DLL isn't available would be easier... Do you have any suggestions how this could be done? Thanks a lot!