使用 PowerShell 运行我的第三方 DLL 文件

问题描述:

我不确定使用 PowerShell 是否可行.

I am not sure if this is possible or not with PowerShell.

但基本上我有一个 Windows Forms 程序,它配置了一个名为 EO Server 的程序.EO Server有一个API,我引用了EOServerAPI.dll来运行下面的代码.

But basically I have a Windows Forms program that configures a program called EO Server. The EO Server has an API, and I make a reference to EOServerAPI.dll to make the following code run.

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 窗体应用程序中相同类型的调用?

Is it possible to interact with an API DLL file and make the same types of calls as you would in a Windows Forms application?

是的,您可以:

Add-Type -Path $customDll
$a = new-object custom.type

您可以像这样调用静态方法:

You call a static method like so:

[custom.type]::method()

你也可以使用反射来代替 Add-Type:

Instead of Add-Type, you can also use reflection:

[Reflection.Assembly]::LoadFile($customDll)

(注意,即使是上面调用的反射库和 LoadFile 静态方法.)

(Note that even the above is calling the Reflection library and the LoadFile static method.)