Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Read version from dll file

Posted on 2008-06-13
4
Medium Priority
?
816 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 2000 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

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
In real business world data are crucial and sometimes data are shared among different information systems. Hence, an agreeable file transfer protocol need to be established.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Six Sigma Control Plans

885 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