Many times we have to register an assembly and only one thing came in mind "regasm" command line utility. But for this also we have to manually type this command and it parameters (assembly name) in command prompt, or we can use the Process class in .NET to call regasm executable, and run through .NET, but there is also another way to register an assembly, and till now I, did not find any issues in this API.

Following is the code to register an assembly through C# code.

using System.Reflection;
using System.Configuration.Assemblies;
using System.Runtime.InteropServices;

Assembly obj = Assembly.LoadFrom(Assembly name);
RegistrationServices reg = new RegistrationServices();
bool result = reg.RegisterAssembly(obj, AssemblyRegistrationFlags.SetCodeBase);