我不确定PowerShell是否可以做到这一点。
但基本上我有一个Windows Forms程序,用于配置一个名为EO服务器的程序。EO服务器有一个应用程序接口,我引用EOServerAPI.dll来运行下面的代码。
using EOserverAPI;
...
private void myButton_Click(object sender, EventArgs e)
{
String MDSConnString="Data Source=MSI;Initial Catalog=EOMDS;Integrated Security=True;";
//Create the connection
IEOMDSAPI myEOMDSAPI = EOMDSAPI.Create(MDSConnString);
//Get JobID
Guid myMasterJobID = myEOMDSAPI.GetJobID("myJobRocks");
}
是否可以与API DLL文件交互并进行与Windows窗体应用程序中相同类型的调用?
发布于 2011-11-02 04:13:57
是的,您可以:
Add-Type -Path $customDll
$a = new-object custom.type
您可以像这样调用静态方法:
[custom.type]::method()
除了Add-Type,您还可以使用反射:
[Reflection.Assembly]::LoadFile($customDll)
(请注意,即使是上面的代码也在调用反射库和LoadFile静态方法。)
发布于 2019-04-20 14:59:07
实际上,其他提供的解决方案对我不起作用,这里是一个完全适合我的替代方案:
$AssemblyPath = "C:\SomePath\SomeLIB.dll"
$bytes = [System.IO.File]::ReadAllBytes($AssemblyPath)
[System.Reflection.Assembly]::Load($bytes)
发布于 2021-05-15 17:29:33
c# dll
Add-Type -Path $dllPath
(new-object namespace.class)::Main() #Where namespace=dllnamespace, class=dllclass, Main()=dllstartvoid
信息。获取命名空间和类
$types = Add-Type -Path $dllPath -PassThru
$types | ft fullname
$types
如果它不是“可执行的”dll ( get/set dll),那么这是我所知道的最好的(不需要vs示例dll创建):
https://kazunposh.wordpress.com/2012/03/19/проверка-корректного-ввода-distinguished-name-в-скри/
https://stackoverflow.com/questions/7972141
复制相似问题