每个已部署应用程序的唯一ID /代码

时间:2013-08-28 12:11:46

标签: visual-studio-2010 deployment publish uniqueidentifier

我相信来自VS的每个部署产品(应用程序)都有一个独特的id或类似的smth,它不会改变分布。我的意思是我发布了一个应用程序并将其交给一个拥有100名员工的公司,并且该产品在安装的每台PC上都保留了相同的唯一ID。

我从程序项目的GUID遇到Assembly Information,但我不确定是那个。那么有什么类似产品的唯一ID,如果是 - 我在哪里可以找到它以及如何在代码本身中访问它。 即:string uniqueID = Something.getProductID()或其他......

1 个答案:

答案 0 :(得分:1)

获取GUID有两种方法,

首先,你可以在装配信息中获得GUID。

//Gets the assembly that contains the code that is currently executing.
Assembly asm = Assembly.GetExecutingAssembly();
Guid id= asm.GetType().GUID;

其次,它不是从程序集信息中获取的。存储为真正的自定义属性。

var attribute = (GuidAttribute)asm.GetCustomAttributes(typeof(GuidAttribute),true)[0].;
var id = attribute.Value;

您可以看到更多信息

Assembly.GetCustomAttributes方法(类型,布尔值)

http://msdn.microsoft.com/en-us/library/88d17d13.aspx

Assembly.GetExecutingAssembly方法

http://msdn.microsoft.com/en-us/library/system.reflection.assembly.getexecutingassembly.aspx

相关问题