Solved

Read version from dll file

Posted on 2008-06-13
4
797 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 Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in 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…

792 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