Solved

Read version from dll file

Posted on 2008-06-13
4
801 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

In this post we will learn different types of Android Layout and some basics of an Android App.
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 …
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…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

710 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