zoukankan      html  css  js  c++  java
  • C#中获取程序集版本号的方法

    我的方法:
    string version = Assembly.GetExecutingAssembly().GetName().Version.ToString();
     
    方法一:
    public void GetFileVersion() {
    FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(Path路径字符串);
    string AssmblyVersion=myFileVersionInfo.FileVersion;
    } 
     
    方法二:
    [assembly: AssemblyTitle("")]
    [assembly: AssemblyDescription("")]
    [assembly: AssemblyConfiguration("")]
    [assembly: AssemblyCompany("")]
    [assembly: AssemblyProduct("")]
    [assembly: AssemblyCopyright("")]
    [assembly: AssemblyTrademark("")]
    [assembly: AssemblyCulture("")]

    修改AssemblyInfo.cs文件的上述信息


    在程序中调用如下:

    Version ApplicationVersion = new Version(Application.ProductVersion);
    string AssmblyVersion = ApplicationVersion.Major;//获取主版本号  



    方法三:
    private void GetEdition()
    {
    Assembly assembly = Assembly.GetExecutingAssembly();
    //this.labelEdition.Text = assembly.FullName;
    
    // 获取程序集元数据
    AssemblyCopyrightAttribute copyright = (AssemblyCopyrightAttribute)
    AssemblyCopyrightAttribute.GetCustomAttribute(Assembly.GetExecutingAssembly(),
    typeof(AssemblyCopyrightAttribute));
    AssemblyDescriptionAttribute description = (AssemblyDescriptionAttribute)
    AssemblyDescriptionAttribute.GetCustomAttribute(System.Reflection.Assembly.GetExecutingAssembly(),
    typeof(AssemblyDescriptionAttribute)); 
    
    string a = description.Description;
    string b = description.Description; 
    string c = copyright.Copyright; 
    string d = Application.ProductVersion;
    }



    方法四:
    string path = @"C:WINNTMicrosoft.NETFrameworkv1.1.4322System.dll";
    Assembly assembly = Assembly.LoadFile(path);
    AssemblyName assemblyName = assembly.GetName();
    Version version = assemblyName.Version;
    Console.WriteLine(assemblyName.FullName);
    string a=version.Major.ToString();
    string b= version.Minor.ToString(); 
    string c=version.Revision.ToString(); 
    string d=version.Build.ToString(); 


    原文链接:http://ruantnt.blog.163.com/blog/static/19052545220118932123551/

     

    慎于行,敏于思!GGGGGG
  • 相关阅读:
    python ddt 传多个参数值示例
    Appium 输入 & 符号,实际输入&-
    curl 调用jenkins的api
    Android WebView的Js对象注入漏洞解决方案
    Could not find com.android.tools.build:gradle:1.3.0.
    react-native疑难
    win上搭建react-native android环境
    gradle大体内容
    android studio This client is too old to work with the working copy at
    sharedPreference
  • 原文地址:https://www.cnblogs.com/GarsonZhang/p/CE.html
Copyright © 2011-2022 走看看