如何调用我的 dll 并在 powershell 脚本中使用它 [英] how to call my dll and use it in powershell script
本文介绍了如何调用我的 dll 并在 powershell 脚本中使用它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有自己的 dll
,它是用 C# 编写的.
现在我想从我的 powershell
脚本中调用它.
我做了以下事情;
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
但是当我执行那个时,它给了我错误
未找到构造函数.找不到适合 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.
推荐答案
你的类有构造函数(至少一个).所以用好的参数创建对象
Your class has got constructors (at least one). So create the object with the good params
$MyCompObj = New-Object MyClass.Student -argumentlist "arg1","Arg2" ...
这篇关于如何调用我的 dll 并在 powershell 脚本中使用它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文