Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Testing the presence of a reference

Testing the presence of a reference

Scheduled Pinned Locked Moved C#
csharpvisual-studiotestingbeta-testinghelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Maercu
    wrote on last edited by
    #1

    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!

    L L M 3 Replies Last reply
    0
    • M Maercu

      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!

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      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

      1 Reply Last reply
      0
      • M Maercu

        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!

        L Offline
        L Offline
        liRetro
        wrote on last edited by
        #3

        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);

        1 Reply Last reply
        0
        • M Maercu

          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!

          M Offline
          M Offline
          Maercu
          wrote on last edited by
          #4

          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!

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups