C# - writing a COM server - Properties mapped to methods

試著忘記壹切 提交于 2019-12-03 17:34:06

You can't have a COM interface with names that overlap the IUnknown method names (QueryInterface, AddRef and Release).

Update

To have your C# class generate a dispinteface (ie. a IDisptach interface for OLE automation binding), decorate your class with ClassInterfaceAttribute:

[ClassInterface(ClassInterfaceType.AutoDispatch)]
class myClass
{
   public string Foo {get;}
   public long Bar();
}

This will generate the automation property Foo and method Bar, as opposed to a raw COM interface.

You ever tried to use the information contained in the link:
Visual Basic: Inspect COM Components Using the TypeLib Information Object Library

[EDIT]
See if tlbimp.exe tool can help you.

Well, I figured it out...

I decompiled with a vb6 decompiler on the target app and exported as a vb6 project.

Opened it with VS 2008, upgraded to VB .Net.

Ran the application and saw the error "cannot cast to IOleObject".

Did a google search, found out that System.Windows.Forms.Control implements this interface, so inheriting from Control fixed my issue.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!