I get serious weirdness using FileVersionInfo.GetVersionInfo () and was hoping someone could help.
The basics of the problem are that I repeat all the files in the folder that calls GetVersionInfo () for each. There are about 300 files. This works fine for all but 2 files. For these DLLs, I get inferior information back from GetVersionInfo ().
To eliminate all other variables, I extracted this call into a simple test application, and it still had the same problem. However, if I built the test application as a Windows application (it was originally a console application), the data returned correctly.
To clarify, the incorrect data returned at startup as a console application is not just null data, as you could get if the file did not contain version information. It contained reasonable data, but only incorrect data. It is as if he is reading it from another file. I searched for a file containing the corresponding version information, but cannot find it.
Why does this simple call work differently if it is created as a console application and not a Windows application?
If anyone can help with this, I would be very grateful.
Rgds, Andy
- Added code
using System; using System.Diagnostics; namespace test { class Program { static void Main(string[] args) { string file = "C:\\ProblemFile.dll"; FileVersionInfo version = FileVersionInfo.GetVersionInfo(file); string fileName = version.FileName; string fileVersion = version.FileVersion; Console.WriteLine(string.Format("{0} : {1}", fileName, fileVersion)); } } }
source share