Why cannot I cast my COM object to the interface it implements in C#?

前端 未结 2 827
醉酒成梦
醉酒成梦 2020-11-30 11:26

I have this interface in the dll (this code is shown in Visual Studio from metadata):

#region Assembly XCapture.dll, v2.0.50727
// d:\\svn\\dashboard\\trunk\         


        
2条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-11-30 12:09

    So, the problem was that my DLL with IDiagnostics interface was generated from a TLB, and that TLB never got registered.

    Since the DLL was imported from the TLB, RegAsm.exe refuses to register the library. So I used the regtlibv12.exe tool to register the TLB itself:

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\regtlibv12.exe "$(ProjectDir)\lib\Diagnostics.tlb"
    

    Then everything magically started to work.

    Since regtlibv12 is not a supported tool, I still don't know how to do this properly.

提交回复
热议问题