Knaks
Knaks

Reputation: 209

FileVersionInfo not working in Win2008 R2

I am trying to use following code on my Windows Server 2008 R2 64-bit (not SP1).

using System;
using System.Collections.Generic;
using System.Text;
using System.Xml;
using System.Diagnostics;
using System.IO;

namespace TestWrite
{
class Program
{
    static void Main(string[] args)
    {

        try
        {

        FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(@"C:\Windows\system32\Notepad.exe");

             Console.WriteLine( "File: " + myFileVersionInfo.FileDescription + '\n' + "Version number: " + myFileVersionInfo.FileVersion);
        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }
        Console.ReadLine();   
    }
}
}

I get this error message: System.DllNotFoundException: Unable to load DLL 'version.dll': The system cannot find the file specified.

Upvotes: 0

Views: 189

Answers (1)

Bart
Bart

Reputation: 385

Be sure to check the following:

  • The System.Diagnostics library works by executing this code

    EventLog[] eventLogs = EventLog.GetEventLogs();
    foreach (EventLog e in eventLogs) {
        Console.WriteLine("{0}:", e.LogDisplayName);
    }
    
  • Like David W points out, check the solution platform (Any CPU or x86 via Solution Configuration Manager)

  • Is the .NET Framework 4.0 is installed properly? Or try a re-install.

Upvotes: 1

Related Questions