How can I get the executing assembly version?

前端 未结 6 1611
慢半拍i
慢半拍i 2020-12-07 13:51

I am trying to get the executing assembly version in C# 3.0 using the following code:

var assemblyFullName = Assembly.GetExecutingAssembly().FullName;
var ve         


        
6条回答
  •  星月不相逢
    2020-12-07 13:56

    using System.Reflection;
    {
        string version = Assembly.GetEntryAssembly().GetName().Version.ToString();
    }
    

    Remarks from MSDN http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getentryassembly%28v=vs.110%29.aspx:

    The GetEntryAssembly method can return null when a managed assembly has been loaded from an unmanaged application. For example, if an unmanaged application creates an instance of a COM component written in C#, a call to the GetEntryAssembly method from the C# component returns null, because the entry point for the process was unmanaged code rather than a managed assembly.

提交回复
热议问题