我创建了一个类并使其可见:
[ComVisible(true)]
[Guid("FD909333-3CD0-477F-8A7E-B8045B0B84EC")]
[ClassInterface(ClassInterfaceType.None)]
[ProgId("TestComApp.TestApp.TestClass")]
public class TestClass:ITestCom
{
public int Add(int a, int b) { return a + b; }
}
此外,界面设置为COM可见:
[ComVisible(true)]
[Guid("26567B41-15DB-4EE2-A277-357EAE96BF6A")]
[InterfaceType(ComInterfaceType.InterfaceIsDual)]
interface ITestCom
{
int Add(int a, int b);
}
但是当我尝试注册DLL时
regsvr32 /i TestComApp.dll
我收到以下错误"模块已加载但未找到入口点DLLRegisterServer"
答案 0 :(得分:1)
要注册.NET DLL,您需要使用Regasm.exe而不是regsvr32.exe。 Regasm.exe位于C:\ Windows \ Microsoft.NET \ Framework \ v4.0.30319(或类似,具体取决于.NET版本)。
还要确保指定/ codebase选项,或者使程序集具有强名称,否则COM将无法找到DLL。