我有.Net c#类库(C:\ path1 \ path2 \ Proj1.Web \ bin \ Proj1.Web.dll)。对象浏览器显示我想要调用的公共函数,如下所示
public void RunMe()
Member of Proj1.Web.Services.RunCustomServices
我正在使用
在powershell中加载程序集$asm=[Reflection.Assembly]::LoadFile("C:\path1\path2\Proj1.Web\bin\Proj1.Web.dll")
[Proj1.Web.Services.RunCustomServices]::RunMe()
方法调用失败,因为 [Proj1.Web.Services.RunCustomServices]不包含名为的方法 “邵仁枚”。在行:1个字符:1 + [Proj1.Web.Services.RunCustomServices] :: RunMe() + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ + CategoryInfo:InvalidOperation:(:) [],RuntimeException + FullyQualifiedErrorId:MethodNotFoundPS C:\ users \ home> [Proj1.Web.Services.RunCustomServices] :: RunMe()方法调用 失败,因为[Proj1.Web.Services.RunCustomServices]不包含 一个名为'RunMe'的方法。在行:1个字符:1 + [Proj1.Web.Services.RunCustomServices] :: RunMe() + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~ + CategoryInfo:InvalidOperation:(:) [],RuntimeException + FullyQualifiedErrorId:MethodNotFound
答案 0 :(得分:1)
由于该函数不是static
(或VB.Net术语中的Shared
),因此您需要创建一个类的实例来调用该方法:
$RCSInstance = New-Object Proj1.Web.Services.RunCustomServices
$RCSInstance.RunMe()