问题
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