Using a COM dll from C# without a type library

前端 未结 7 2156
梦谈多话
梦谈多话 2020-12-14 12:23

I need to use a COM component (a dll) developed in Delphi ages ago. The problem is: the dll does not contain a type library... and every interop feature (eg. TlbImp) in .NET

7条回答
  •  轮回少年
    2020-12-14 13:07

    Yes and no.

    All C# (and any CLR language) needs in order communicate with a COM object is a compatible interface signature. Typically specifying the methods, GUID and apartment style of the interface. If you can add this definition into your code base then the TLB is not necessary.

    There is a small caveat that comes with that statement. I believe you will get into trouble if you try and use a COM object across apartment boundaries and don't have a suitable TLB registered. I can't 100% remember on this point though.

提交回复
热议问题