cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
sthoeum
Level 3

DotNetCoCreateObject : Invalid number of parameters.

In my Basic MSI project,

I used DotNetCoCreateObject in the installscript to instanciate my Installhelper.dll and then call a method in it.
Everything works fine , until
I declare 2 methods or more with the same name but different parameters in the installhelper.dll.
Then during the installation , the call to the method with different parameters does not work it gives error -2147352562 : Invalid number of parameters.

If I give a different method name, then it works.

Is there a limitation that you cannot declare more than one method with the same name?
Labels (1)
0 Kudos
(1) Reply
joshstechnij
Level 10 Flexeran
Level 10 Flexeran

The is more likely an issue with the COM support that allows for calling COM objects or .NET assemblies in InstallScript. The InstallScript engine works with COM through the use of IDispatch. IDispatch::GetIDsOfNames is used to find the dispatch ID of the given method/property name on an object. The GetIDsOfNames method does not provide any way to differentiate multiple methods with the same name (and normally this is implemented by returning the first match with typelibrary information to the requested method name). As such, IDispatch (and COM) don't really support method overloads.

If this assembly was registered for COM interop and then a VBScript with roughly the same code was run, the same behavior would likely be seen.

As a workaround, using different method names is recommended. As an alternate approach, a Managed Custom Action can be used (in MSI projects) to call a method in a .NET assembly. This functionality works differently to how InstallScript supports .NET assembly calls and may provide more flexibility in this specific case.
0 Kudos