I have a managed assembly containing several classes, and these classes have overloaded methods. I provide assembly to callers COM / IDispatch through
[ComVisible(true)]
.., and also install the correct Guid on the assembly itself. I do not define an explicit interface for COM interoperability. All this is done dynamically. I run regasm.exe /codebasein a managed DLL and register it for COM interaction.
When I launch OleView, I can see the ProgId of various classes in the assembly. But looking through these ProgIds and expanding the IDispatch node, there is no TypeLib information for these classes.
However, from a script, I can call a method that takes null arguments or a method that takes a single argument. If there is an overload that takes more than one argument, I cannot call this method by name. The error I get is sequentially
Microsoft VBScript runtime error: Wrong number of arguments or invalid property assignment: <methodname>
From this, I realized that the COM / IDispatch clients were not able to correctly resolve the overloaded methods for an object opened through COM interaction.
Then i added
[ClassInterface(ClassInterfaceType.AutoDual)]
... to each of the classes in question. After regasm.exein the DLL, I can see typelib information for each method in the IDispatch node.
I found that overloaded methods automatically get a name that includes the suffix with the append. MethodX will expose overloads in the automatically generated typelib assembly like MethodX, MethodX_2, MethodX_3, etc.
, , , , .
, [ClassInterface(ClassInterfaceType.AutoDual)] , , Wrong number of arguments or invalid property assignment.
: - - ? ? ?