Solved

Read version from dll file

Posted on 2008-06-13
4
791 Views
Last Modified: 2010-04-21
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
0
Comment
Question by:joelilly
  • 2
4 Comments
 
LVL 10

Expert Comment

by:peetm
ID: 21783026
>>VSTO

No idea what that is, but, check out the FileSystemObject's GetFileVersion method.
0
 
LVL 38

Accepted Solution

by:
PaulHews earned 500 total points
ID: 21783097
In .NET use the FileVersionInfo class
http://msdn.microsoft.com/en-us/library/system.diagnostics.fileversioninfo(VS.71).aspx
MsgBox(FileVersionInfo.GetVersionInfo("C:\WINDOWS\opuc.dll").FileVersion)

Open in new window

0
 

Author Closing Comment

by:joelilly
ID: 31467088
Thanks!
0
 

Author Comment

by:joelilly
ID: 21783170
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.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
This is about my first experience with programming Arduino.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now