I\'m trying to access a .Net library (The Image Resizer) from COM (jscript).
I\'ve tried both IDispatch and class interface generation, as well as [ClassInterface( Clas
Overloading does not work for the interop layer to COM. You could however use optional parameters and hide all other methods from the COM layer:
// COM won't see this.
[ComVisible(false)]
void Test(string a)
// COM will see this and parameter b is not required
void Test(string a, [DefaultParameterValue(null)] string b)
True that COM doesn't "do" method overloading.
BUT. see http://msdn.microsoft.com/en-us/library/ms182197(v=vs.80).aspx .
This is a doc page on FxCop, a static analysis tool. But there's a tidbit of information there, which is useful for COM developers:
When overloaded methods are exposed to COM clients, only the first method overload retains its name. Subsequent overloads are uniquely renamed by appending to the name an underscore character '_' and an integer that corresponds to the order of declaration of the overload.
and also see
Overloads in COM interop (CCW) - IDispatch names include suffix (_2, _3, etc)
So, through the COM layer, you could call your original methods with
Build_2("file", "file", s);
Build_3("file", "file", settings);