public static List<System.Type> RegisterComTypes(string filePath)
{
// load assmebly.
Assembly assembly = Assembly.LoadFrom(filePath);
// check that the correct assembly is being registered.
VerifyCodebase(assembly, filePath);
RegistrationServices services = new RegistrationServices();
// list types to register/unregister.
List<System.Type> types = new List<System.Type>(services.GetRegistrableTypesInAssembly(assembly));
// register types.
if (types.Count > 0)
{
// unregister types first.
if (!services.UnregisterAssembly(assembly))
{
throw new ApplicationException("Unregister COM Types Failed.");
}
// register types.
if (!services.RegisterAssembly(assembly, AssemblyRegistrationFlags.SetCodeBase))
{
throw new ApplicationException("Register COM Types Failed.");
}
}
return types;
}