I am trying to create an instance of given type in PowerShell using New-Object. The constructor of the type being instantiated is having an argument of type [string params]. For example,
public class Test
{
public Test(params string[] data)
{
//
}
}
If I try to instantiate the above type using following command:
$ins = New-Object Test
I am getting the following error:
System.Management.Automation.PSArgumentException: Constructor not found. Cannot find an appropriate constructor for type.....
What is the correct way of instantiating the above type? I don't want to pass any dummy or empty string as input parameter.
The above sample code was only for demonstration purposes. The class that I am trying to instantiate is StandardKernel from Ninject library. The class definition is given below:
public class StandardKernel : KernelBase
{
public StandardKernel(params INinjectModule[] modules)
: base(modules)
{
}
public StandardKernel(INinjectSettings settings, params INinjectModule[] modules)
: base(settings, modules)
{
}
}
The following code works fine in C#:
var kernel = new StandardKernel()
public StandardKernel() : base() {}.