I've been using System.EnterpriseServices.Internal.Publish.RegisterAssembly('Path to assembly.dll')
to register my assembly, but I need to create a type library and register that also.
I've tried using RegisterTypeLib:
[DllImport("oleaut32.dll")]
static extern int RegisterTypeLib(ITypeLib ptlib, [MarshalAs(UnmanagedType.BStr)] string szFullPath, [MarshalAs(UnmanagedType.BStr)] string szHelpDir);
like this :
Assembly asm = Assembly.LoadFrom(TheAction[2]);
RegistrationServices regAsm = new RegistrationServices();
bool bResult = regAsm.RegisterAssembly(asm, AssemblyRegistrationFlags.SetCodeBase);
TypeLibConverter converter = new TypeLibConverter();
ConversionEventHandler eventHandler = new ConversionEventHandler();
ITypeLib typeLib = (ITypeLib)converter.ConvertAssemblyToTypeLib(asm, TheAction[2].Replace (".dll",".tlb"), 0, eventHandler);
RegisterTypeLib(typeLib, TheAction[2].Replace(".dll", ".tlb"), string.Empty);
It throws no error, so how can I check if it worked?
Also, if there is a simpler way to do this from C# I'd love to hear about it :)