.NET exception to throw for "xyz software not installed" or "required windows feature not installed/not detected"

76 Views Asked by At

Just as the title states, I'm curious as to what .NET exception would best fit a scenario where a dependent piece of software (3rd party application, Windows optional feature/role, etc) -- not necessarily a dll dependency or library -- is confirmed as missing or can't be detected/determined for various reasons (permissions, etc).

  • This scenario assumes that minimum system requirement checks have thus far passed (OS, architecture, environment, access rights, hardware, etc).
  • PlatformNotSupportedException doesn't seem appropriate as it describes the platform as being part of the failure -- and this exception should be thrown prior to even arriving to code that checks "Is the required XYZ software/feature installed or not?".
  • FileNotFoundException doesn't describe the situation accurately because checking file paths isn't always a reliable method of determining "Is XYZ software/feature installed or not?" -- install paths can change, uninstalled leftovers can be present/corrupt and produce a false positive evaluation of "File is present, therefore XYZ software is considered to be installed/registered", etc.
  • STATUS_SXS_ASSEMBLY_MISSING (0x80073701) The description for this is "The referenced assembly is not installed on your system."
    • I haven't found much documentation on this error, but my interpretation is that this is usually witnessed specifically in the context of a failed Windows update/component/feature installation -- and not typically used in the scenario described in this question where the missing piece of software is a 3rd party application.
      • It does, however, seem to be a possible option when the missing piece of software is a Windows component/feature/role.
    • My efforts to find a resource that maps this to a .NET exception have come up empty.
  • Throwing a Win32Exception in .NET is an option, but so far I haven't found one that seems fitting.



Is creating a custom exception the best approach to this? This scenerio doesn't strike me as being an edge-case where a custom exception is the most common approach used in the wild, so I'm hoping that I'm just stupid and haven't yet found the best exception in the .NET API documentation to use.

0

There are 0 best solutions below