Assembly attributes in .net
2009-05-05 12:34
225 查看
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace AssemblyAttributesCS
{
class Program
{
static void Main(string[] args)
{
Assembly a = Assembly.GetExecutingAssembly();
Type assemblyType = typeof(AssemblyDescriptionAttribute);
object[] attributes = a.GetCustomAttributes(assemblyType, false);
if (attributes.Length > 0)
{
AssemblyDescriptionAttribute ada = attributes[0] as AssemblyDescriptionAttribute;
Console.WriteLine("Description is {0}", ada.Description);
}
Console.Read();
}
}
}
VB.NET:
Imports System.Reflection
Module Module1
Sub Main()
Dim a As Assembly = Assembly.GetExecutingAssembly()
Dim assemblyType As Type = GetType(AssemblyDescriptionAttribute)
Dim attributes As Object() = a.GetCustomAttributes(assemblyType, False)
If attributes.Length > 0 Then
Dim ada As AssemblyDescriptionAttribute = CType(attributes(0), AssemblyDescriptionAttribute)
Console.WriteLine("Description is {0}", ada.Description)
End If
Console.Read()
End Sub
End Module
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace AssemblyAttributesCS
{
class Program
{
static void Main(string[] args)
{
Assembly a = Assembly.GetExecutingAssembly();
Type assemblyType = typeof(AssemblyDescriptionAttribute);
object[] attributes = a.GetCustomAttributes(assemblyType, false);
if (attributes.Length > 0)
{
AssemblyDescriptionAttribute ada = attributes[0] as AssemblyDescriptionAttribute;
Console.WriteLine("Description is {0}", ada.Description);
}
Console.Read();
}
}
}
VB.NET:
Imports System.Reflection
Module Module1
Sub Main()
Dim a As Assembly = Assembly.GetExecutingAssembly()
Dim assemblyType As Type = GetType(AssemblyDescriptionAttribute)
Dim attributes As Object() = a.GetCustomAttributes(assemblyType, False)
If attributes.Length > 0 Then
Dim ada As AssemblyDescriptionAttribute = CType(attributes(0), AssemblyDescriptionAttribute)
Console.WriteLine("Description is {0}", ada.Description)
End If
Console.Read()
End Sub
End Module
相关文章推荐
- Reading Assembly attributes in VB.NET
- Study Attributes in .net
- How to use HTML-5 data-* attributes in ASP.NET MVC
- How to debug a Private Module Assembly in DotNetNuke?
- Error 1 Project file must include the .NET Framework assembly 'PresentationCore, PresentationFramework' in the reference
- enable assembly bind failure logging (Fusion) in .NET
- Top 2 things you should know about the Global Assembly Cache (GAC) in .NET 4.0
- 无法打开模块文件“C:\Users\sq\AppData\Local\Temp\.NETFramework,Version=v4.5,AssemblyAttributes.vb”:系统找不到指定的文件
- ASP.Net MVC Entity Framework Error – More than one context type was found in the assembly ‘ProjectNa
- Reflection - assembly in .net
- How to Determine if a file is a .Net assembly (in Delphi and C#)
- Creating a SharePoint BCS .NET Connectivity Assembly to Crawl RSS Data in Visual Studio 2010
- get assemblyinfo.cs version info in asp.net 2.0
- .net core An assembly specified in the application dependencied mainfest<****.json>was not found解决办法
- WinForm Vs WPF, COM/COM+ Vs .Net Assembly, COM/COM+ in ASP.Net, ... ...
- Spark代码调试遇到的错误Caused by: java.net.URISyntaxException: Relative path in absolute URI: file:
- [转]An introduction to OAuth 2.0 using Facebook in ASP.NET Core
- Asp.net Attributes添加额外属性
- Thread Synchronization in .NET
- Developing Software in Visual Studio .NET with Non-Administrative Privileges