我的方法:
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:\WINNT\Microsoft.NET\Framework\v1.1.4322\System.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/

C#中获取程序集版本号的方法的更多相关文章

  1. Windows Store 应用中获取程序集版本号的方法

    本文为个人博客备份文章,原文地址: http://validvoid.net/windows-store-app-get-assembly-version/ WinRT 中对反射做了很多限制,假设 W ...

  2. python中获取python版本号的方法【转】

    原文 python3 #!/usr/bin/python # 第1种方法 import platform print(platform.python_version()) >>> i ...

  3. python中获取python版本号的方法

    import platform print platform.python_version()

  4. android中获取root权限的方法以及原理(转)

    一. 概述 本文介绍了android中获取root权限的方法以及原理,让大家对android 玩家中常说的“越狱”有一个更深层次的认识. 二. Root 的介绍 1. Root 的目的 可以让我们拥有 ...

  5. dede织梦栏目页和文章页中获取当前栏目名称方法

    一般情况下,在dede织梦系统中列表页.栏目页和文章页中获取当前所在栏目名称只需要代码:{dede:type}[field:typename]{/dede:type}即可,不需要定义ID,默认的就是当 ...

  6. Android中获取文件路径的方法总结及对照

    最近在写文件存贮,Android中获取文件路径的方法比较多,所以自己也很混乱.找了好几篇博客,发现了以下的路径归纳,记录一下,以备不时之需 Environment.getDataDirectory() ...

  7. LoadRunner中获取当前系统时间方法

    LoadRunner中获取当前系统时间方法 发表于:2017-6-02 11:41  作者:人生_0809   来源:51Testing软件测试网采编 字体:大 中 小 | 上一篇 | 下一篇 | 打 ...

  8. Java编程中获取键盘输入实现方法及注意事项

    Java编程中获取键盘输入实现方法及注意事项 1. 键盘输入一个数组 package com.wen201807.sort; import java.util.Scanner; public clas ...

  9. IndexOf、LastIndexOf、Substring的用法及C# foreach 中获取索引index的方法

     String.IndexOf String.IndexOf 方法 (Char, Int32, Int32)报告指定字符在此实例中的第一个匹配项的索引.搜索从指定字符位置开始,并检查指定数量的字符位置 ...

随机推荐

  1. 转:MyEclipse8.6插件安装方法

    通常,我们可以用update来直接安装.但是myeclipse限制了中国区的下载和更新.所以我们只能用插件配置的方法来实现. MyEclipse8.6插件安装同Eclipse插件安装方式大致相同,如下 ...

  2. BPM 应用系统开发案例实战

    概述 IBM BPM 的前身是 Lombardi,是由 IBM 于 2009 年收购的产品,之后产品更名为 IBM WebSphere Lombardi Edition,目前最新版本称为 IBM BP ...

  3. YUI3 CSS

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/stri ...

  4. 关于undefined reference to `WSASocketA@24'问题的解决

    关于 Eclipse 开发C++ Socket  ,在开发的过程中 用WinGW 平台编译, 示例server端: #include <winsock2.h> #include <m ...

  5. 兼容IE, Chrome的ajax function

    gAjax.js var gAjax = (function () { /* paramObj:{ url: request url, method: GET or POST, encode: cha ...

  6. game of life

    class Solution { public: void gameOfLife(vector<vector<int>>& board) { queue<int& ...

  7. Temporary InMemory Tables [AX 2012]

    Temporary InMemory Tables [AX 2012] This topic has not yet been rated - Rate this topic Updated: Oct ...

  8. nohup DEMO

    nohup,顾名思义:挂起免疫. nohup命令可以防止当你退出系统时,在后台运行的进程被终止.它能让你运行的命令或脚本在你退出系统后继续在后台运行. nohup命令不能自动的将任务放在后台运行,所以 ...

  9. 几个常见的Laravel报错及解决方法

    报错:「Can't swap PDO instance while within transaction」 transactions >= 1) {throw new RuntimeExcept ...

  10. JavaEE基础(十三)

    1.常见对象(StringBuffer类的概述) A:StringBuffer类概述 通过JDK提供的API,查看StringBuffer类的说明 线程安全的可变字符序列 B:StringBuffer ...