Assembly attributes in .net
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();
}
}
}
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
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