Reflection - assembly in .net
c#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace ReflectionCS
{
class Program
{
static void Main(string[] args)
{
String path = @"C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll";
Assembly assembly = Assembly.LoadFile(path);
ShowAssemblyInfo(assembly);
Assembly currentAssembly = Assembly.GetExecutingAssembly();
ShowAssemblyInfo(currentAssembly);
Console.ReadLine();
}
static void ShowAssemblyInfo(Assembly assembly)
{
Console.WriteLine(assembly.FullName);
Console.WriteLine("From GlobalAssemblyCache? {0}", assembly.GlobalAssemblyCache);
Console.WriteLine("Path: {0}", assembly.Location);
Console.WriteLine("Version: {0}", assembly.ImageRuntimeVersion);
foreach (Module module in assembly.GetModules())
{
Console.WriteLine("Module: {0}", module.Name);
}
Console.WriteLine();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
namespace ReflectionCS
{
class Program
{
static void Main(string[] args)
{
String path = @"C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll";
Assembly assembly = Assembly.LoadFile(path);
ShowAssemblyInfo(assembly);
Assembly currentAssembly = Assembly.GetExecutingAssembly();
ShowAssemblyInfo(currentAssembly);
Console.ReadLine();
}
static void ShowAssemblyInfo(Assembly assembly)
{
Console.WriteLine(assembly.FullName);
Console.WriteLine("From GlobalAssemblyCache? {0}", assembly.GlobalAssemblyCache);
Console.WriteLine("Path: {0}", assembly.Location);
Console.WriteLine("Version: {0}", assembly.ImageRuntimeVersion);
foreach (Module module in assembly.GetModules())
{
Console.WriteLine("Module: {0}", module.Name);
}
Console.WriteLine();
}
}
}
vb.net:
Imports System.Reflection
Module Module1
Sub Main()
Dim path As String = "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll"
Dim assembly As Assembly = assembly.LoadFile(path)
ShowAssemblyInfo(assembly)
Dim currentAssembly As Assembly = assembly.GetExecutingAssembly()
ShowAssemblyInfo(currentAssembly)
Console.ReadLine()
End Sub
Sub ShowAssemblyInfo(ByVal assembly As Assembly)
Console.WriteLine(assembly.FullName)
Console.WriteLine("From GlobalAssemblyCache? {0}", assembly.GlobalAssemblyCache)
Console.WriteLine("Path: {0}", assembly.Location)
Console.WriteLine("Version: {0}", assembly.ImageRuntimeVersion)
For Each [Module] As [Module] In assembly.GetModules
Console.WriteLine("Module: {0}", [Module].Name)
Next
Console.WriteLine()
End Sub
End Module
Module Module1
Sub Main()
Dim path As String = "C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll"
Dim assembly As Assembly = assembly.LoadFile(path)
ShowAssemblyInfo(assembly)
Dim currentAssembly As Assembly = assembly.GetExecutingAssembly()
ShowAssemblyInfo(currentAssembly)
Console.ReadLine()
End Sub
Sub ShowAssemblyInfo(ByVal assembly As Assembly)
Console.WriteLine(assembly.FullName)
Console.WriteLine("From GlobalAssemblyCache? {0}", assembly.GlobalAssemblyCache)
Console.WriteLine("Path: {0}", assembly.Location)
Console.WriteLine("Version: {0}", assembly.ImageRuntimeVersion)
For Each [Module] As [Module] In assembly.GetModules
Console.WriteLine("Module: {0}", [Module].Name)
Next
Console.WriteLine()
End Sub
End Module