Link to home
Start Free TrialLog in
Avatar of joelilly
joelilly

asked on

Read version from dll file

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.

Thanks,
Joe
Avatar of peetm
peetm
Flag of United Kingdom of Great Britain and Northern Ireland image

>>VSTO

No idea what that is, but, check out the FileSystemObject's GetFileVersion method.
ASKER CERTIFIED SOLUTION
Avatar of PaulHews
PaulHews
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of joelilly
joelilly

ASKER

Thanks!
peetm: I'd been trying that until I read on MSDN that the filesystemobject doesn't provide version info.  (see http://support.microsoft.com/kb/189751)  The alternate solution there was to use the GetFileVersionInfo Windows API which, is what I was trying to avoid.   Isn't that obsolete?  The FileVersionInfo class that PaulHews posted is what I was looking for.