以编程方式注册 C#/VB.NET COM dll [英] Register a C#/VB.NET COM dll programmatically
问题描述
问题:我有一个从 C++ 程序中使用的 .NET dll.现在我必须在部署计算机上以编程方式注册 dll.
Question: I have a .NET dll which I use from a C++ program. Now I have to register the dll programmatically on a deployment computer.
我该怎么做(以编程方式!不使用 regasm)?我记得,当我从 C++ dll 中调用 VB6 dll 时,我不得不使用 DllRegisterServer 和 DllUnregisterServer.
How do I do that (programmatically! not using regasm)? I remember, when I once called a VB6 dll from a C++ dll, I had to use DllRegisterServer and DllUnregisterServer.
.NET dll 仍然如此吗?
看来我必须以某种方式将 dllregisterserver 函数添加到 .NET dll.
Is that still so with a .NET dll?
It seems I have to somehow add the dllregisterserver function to the .NET dll.
推荐答案
YUK,.NET dll 没有 DllRegisterServer,所以你必须编写一个 .NET 安装程序,在某处执行:
YUK, .NET dlls don't have DllRegisterServer, so you have to write a .NET installer, executing this somewhere:
Assembly asm = Assembly.LoadFile (@"c: empImageConverter.dll");
RegistrationServices regAsm = new RegistrationServices();
bool bResult = regAsm.RegisterAssembly(asm, AssemblyRegistrationFlags.SetCodeBase);
这篇关于以编程方式注册 C#/VB.NET COM dll的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!