FileVersionInfo no funciona en 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.

preguntado el 28 de agosto de 12 a las 13:08

Is this a 64-bit or 32-bit application? -

In V.S., platform target is set to 'Any CPU'. -

Just for grins, recompile your application and change the target to X86, which should force the target into a 32-bit application. If the error persists, I'd check for the presence of \windows\system32\version.dll on the target machine. -

1 Respuestas

Be sure to check the following:

  • Programas de System.Diagnostics library works by executing this code

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

  • Es el .NET Framework 4.0 is installed properly? Or try a re-install.

contestado el 23 de mayo de 17 a las 11:05

I'm missing the connection the first bullet point has to the question. - Jesse C. Rebanadora

The first bullet point was another test case to check the framework - Bart

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.