Runtime class and object in .net
C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Reflection.Emit;
namespace BindingFlagsCS
{
class Program
{
static void Main(string[] args)
{
AssemblyName an = new AssemblyName();
an.Name = "Runtime assembly";
an.Version = new Version("1.0.0.0");
AppDomain ad = AppDomain.CurrentDomain;
AssemblyBuilder ab = ad.DefineDynamicAssembly(an, AssemblyBuilderAccess.ReflectionOnly);
ModuleBuilder mb = ab.DefineDynamicModule("Runtime", "Runtime.dll");
TypeBuilder tb = mb.DefineType("Joey", TypeAttributes.Public);
Type joey = tb.CreateType();
Console.WriteLine("Type's full name: "+joey.FullName);
foreach (MemberInfo mi in joey.GetMembers())
{
Console.WriteLine("Member ({0}): {1}", mi.MemberType, mi.Name);
}
Console.Read();
}
}
}
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using System.Reflection.Emit;
namespace BindingFlagsCS
{
class Program
{
static void Main(string[] args)
{
AssemblyName an = new AssemblyName();
an.Name = "Runtime assembly";
an.Version = new Version("1.0.0.0");
AppDomain ad = AppDomain.CurrentDomain;
AssemblyBuilder ab = ad.DefineDynamicAssembly(an, AssemblyBuilderAccess.ReflectionOnly);
ModuleBuilder mb = ab.DefineDynamicModule("Runtime", "Runtime.dll");
TypeBuilder tb = mb.DefineType("Joey", TypeAttributes.Public);
Type joey = tb.CreateType();
Console.WriteLine("Type's full name: "+joey.FullName);
foreach (MemberInfo mi in joey.GetMembers())
{
Console.WriteLine("Member ({0}): {1}", mi.MemberType, mi.Name);
}
Console.Read();
}
}
}
VB.NET:
Imports System.Reflection
Imports System.Reflection.Emit
Module Module1
Sub Main()
Dim an As AssemblyName = New AssemblyName
an.Name = "Runtime assembly"
an.Version = New Version("1.0.0.0")
Dim ad As AppDomain = AppDomain.CurrentDomain
Dim ab As AssemblyBuilder = ad.DefineDynamicAssembly(an, AssemblyBuilderAccess.ReflectionOnly)
Dim mb As ModuleBuilder = ab.DefineDynamicModule("RunTime", "Runtime.dll")
Dim tb As TypeBuilder = mb.DefineType("Joey", TypeAttributes.Public)
Dim joey As Type = tb.CreateType
Console.WriteLine("Type's full name: " + joey.FullName)
For Each mi As MemberInfo In joey.GetMembers
Console.WriteLine("Member ({0}): {1}", mi.MemberType, mi.Name)
Next
Console.Read()
End Sub
End Module
Module Module1
Sub Main()
Dim an As AssemblyName = New AssemblyName
an.Name = "Runtime assembly"
an.Version = New Version("1.0.0.0")
Dim ad As AppDomain = AppDomain.CurrentDomain
Dim ab As AssemblyBuilder = ad.DefineDynamicAssembly(an, AssemblyBuilderAccess.ReflectionOnly)
Dim mb As ModuleBuilder = ab.DefineDynamicModule("RunTime", "Runtime.dll")
Dim tb As TypeBuilder = mb.DefineType("Joey", TypeAttributes.Public)
Dim joey As Type = tb.CreateType
Console.WriteLine("Type's full name: " + joey.FullName)
For Each mi As MemberInfo In joey.GetMembers
Console.WriteLine("Member ({0}): {1}", mi.MemberType, mi.Name)
Next
Console.Read()
End Sub
End Module