C# and COM, IFontDisp getting converted to StdFont

我怕爱的太早我们不能终老 提交于 2019-12-13 05:53:00

问题


I am creating a COM (User Control) in C# to be used in Excel-VBA. It compiles without error and I can register it on my machine.

In this COM I have the property declared like this stdole.IFontDisp Font_Test { get; set; }

But in the VBA, the return type automatically gets changed to stdole.StdFont

So in VBA it becomes stdole.StdFont Font_Test

Why is this automatic type conversion is happening and how can I fix this?

Thanks!

Edit:

As per Hans's answer I checked the type library and yes it gets converted to FONT in C# export.

C# : Type Lib [id(0x60020062), propget] HRESULT Font_Test([out, retval] Font** pRetVal); [id(0x60020062), propputref] HRESULT Font_Test([in] Font* pRetVal);

OCX Type Lib: [id(0xfffffe00), propget, helpstring("Returns a Font object."), helpcontext(0x000335af)] HRESULT Font([out, retval] IFontDisp** ppFontDisp); [id(0xfffffe00), propputref, helpstring("Returns a Font object."), helpcontext(0x000335af)] HRESULT Font([in] IFontDisp* ppFontDisp);

来源:https://stackoverflow.com/questions/37734975/c-sharp-and-com-ifontdisp-getting-converted-to-stdfont

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