Hello! And do not tell me how to display the version of the current assembly inside the program. I just need to display it in a text file after launching the program, but I haven’t found anything anywhere on Google.

Thanks a lot in advance!

    2 answers 2

    Try

    Assembly.GetExecutingAssembly().GetName().Version 

    Or

     Assembly.LoadFile('имя_сборки').GetName().Version 

    Read more about Assembly here.

    • Only, LoadFile does not seem to me a good idea: why load an already loaded assembly, and bypassing the cache? - VladD
    • @VladD bypassing which cache? - Pavel Mayorov
    • @PavelMayorov: Loaded builds. The build will reload even though it is already loaded. - VladD
    • @VladD, I agree, the second option is redundant. - Max Zhukov
    • one
      @VladD In the case of ASP.NET, there really is a cache. When updating the bin contents, IIS copies the assemblies somewhere to a temporary directory and then loads them from there. If you make LoadFile, then the assembly will be loaded from bin, not from the cache, and the file will be loaded. - kmv

    You can get the current build version as follows:

     Assembly.GetExecutingAssembly().GetName().Version 

    The Version property is of type System.Version .