當我嘗試使用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個接口。有沒有辦法讓字符串工作?