C# 如何取得自已类库或EXE的GUID值?

SmartLive 2011-04-16 11:38:46
在AssemblyInfo.cs中

// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("MJCOM")]
[assembly: AssemblyDescription("AssemblyDescription")]
[assembly: AssemblyConfiguration("AssemblyConfiguration")]
[assembly: AssemblyCompany("AssemblyCompany")]
[assembly: AssemblyProduct("MJCOM")]
[assembly: AssemblyCopyright("Copyright © 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("e1ede141-b32f-46e0-b20c-a2dedfcf2e95")]

// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

包含有[assembly: Guid("e1ede141-b32f-46e0-b20c-a2dedfcf2e95")]
这样的信息,请问,如何可以取到这个GUID值?
...全文
334 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
transferring 2011-04-17
  • 打赏
  • 举报
回复
要结贴了,接分。
SmartLive 2011-04-17
  • 打赏
  • 举报
回复
感谢支持,结贴!
xiaoqiu1234 2011-04-17
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 gomoku 的回复:]
从metadata中拿信息就是反射:

Assembly code

Assembly asm = ...; //this.GetType().Assembly
Type type = typeof(System.Runtime.InteropServices.GuidAttribute);
foreach(GuidAttribute guid in asm.GetCustom……
[/Quote]
gomoku 2011-04-17
  • 打赏
  • 举报
回复
从metadata中拿信息就是反射:

Assembly asm = ...; //this.GetType().Assembly
Type type = typeof(System.Runtime.InteropServices.GuidAttribute);
foreach(GuidAttribute guid in asm.GetCustomAttributes(type, false))
{
MessageBox.Show( guid.Value );
}

110,534

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧