Finding and Creating Assembly Types
using System;
using System.Reflection;
public class MainClass
{
static void Main(string[] args)
{
Assembly XMLAssembly;
Type[] XMLTypes;
XMLAssembly = Assembly.Load("System.Xml, Version=1.0.3300.0, Culture=neutral, PublicKeyToken=b77a5c561934e089");
XMLTypes = XMLAssembly.GetExportedTypes();
foreach(Type XMLType in XMLTypes) {
object NewObject;
try {
Console.Write(XMLType.ToString());
NewObject = XMLAssembly.CreateInstance(XMLType.ToString());
if(NewObject != null)
Console.WriteLine(" - Creation successful");
else
Console.WriteLine(" - CREATION ERROR");
} catch(Exception e) {
Console.WriteLine(" - EXCEPTION: {0}", e.Message);
}
}
}
}
Related examples in the same category