Read version from dll file
Posted on 2008-06-13
How do I determine (programmatically) what version of VSTO runtime the user is running?
My objective is to write out a logfile for a VS Tools for Office, Outlook Addin, upon catching any exception. My app installs the runtime (a requirement) to C:\Program Files\Common Files\Microsoft Shared\VSTO\8.0\AddinLoader.dll. I can manually determine the version of this file but I want to do this in code for logging. Also, I can manually determine the version in the registry in the Update key of HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\vsto runtime Setup\v8.0.50727. I'd rather avoid reading the registry in code in case the user isn't authorized. Is reading the version of a file object the correct way to do this?
I recall doing this in VB6 and am hoping to find a better way in .NET.