当我尝试使用ComSourceInterfaces而不是typeof字符串参数时,我无法将程序集注册为COM对象。我正在实现多个接口,因为这是SDK所要求的。当我尝试使用ComSourceInterfaces而不是typeof字符串参数时,我无法将程序集注册为COM对象
当我使用
[ComVisible(true),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces("IAccessControl"),
Guid("738CFFEF-37DC-4C61-957E-C5A78FE20223")]
public class EventGeneratorV2 : IAccessControl
我得到的错误
错误MSB3217:无法注册程序集 “... \事件产生v2.dll”。无法从程序集'加载类型'IAccessControl'事件 Generator v2,Version = 1.1.0.0,Culture = neutral, PublicKeyToken = bffdb712704a75b7'。
但是,如果我改变我的代码使用
[ComVisible(true),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(IAccessControl)),
Guid("738CFFEF-37DC-4C61-957E-C5A78FE20223")]
public class EventGeneratorV2 : IAccessControl
它正确地做工作。我也尝试了IAccessControl接口的完全限定名,Lib.Interfaces.IAcccessControl作为字符串,但仍然失败。最好的解决方案是使用多个ComSourceInterfaces,但只能使用一次,最多使用4个接口。为了与其他软件兼容,我需要实现9个接口。有没有办法让字符串工作?