I have my own dll
which written in c#.
Now I want to call that from my powershell
script.
I did the following;
[System.Reflection.Assembly]::LoadFile("E:\MyClass.dll")
$MyCompObj = New-Object MyClass.Student
But when I executing that, it giving me error
Constructor not found. Cannot find an appropriate constructor for type MyClass.Student
Am I following a wrong way to do this??
Please help me to fix this.
Another way to register the DLL files is by using a command-line interface like MS-DOS or PowerShell. First, we will open the command line interface from the Start Menu. In the following example, we will open the PowerShell. Now we will type the regsvr32 command like below.
To execute the program, you need to use the ampersand (&) sign followed by the full path of the program. Another way to execute the program is to browse to that directory and run the program. and run the program name. So far, we have executed the program with the full pathname.
Your class has got constructors (at least one). So create the object with the good params
$MyCompObj = New-Object MyClass.Student -argumentlist "arg1","Arg2" ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With