【发布时间】:2010-11-30 00:01:39
【问题描述】:
我正在尝试使用 PowerShell v2 调用这个非常简单的 .NET 4 函数。它的定义如下:
公共共享功能 currentSchoolYear() 作为字符串 NM4.SiteAdmin.Logic.Subscription 的成员
让我们添加包含该函数的 DLL 文件的路径。这是一个ASP.NET MVC Web 应用程序 DLL 文件。
PS> Add-Type -Path C:\xxx\bin\xxxWebApp.dll
让我们尝试一下(失败!):
PS >
[NM4.SiteAdmin.Logic.Subscription]::currentSchoolYear()
异常调用“currentSchoolYear”
带有“0”参数:“类型
的初始化器 'NM4.SiteAdmin.Logic.Subscription'
抛出异常。”在 line:1 char:54
+ [NM4.SiteAdmin.Logic.Subscription]::currentSchoolYear
+ CategoryInfo : 未指定: (:) [],
方法调用异常
+ FullyQualifiedErrorId : DotNetMethodException
让我们从 PowerShell 观察课程:
PS >
[NM4.SiteAdmin.Logic.Subscription]
IsPublic IsSerial 名称
基本类型
-------- -------- ---- -------- True False 订阅
系统对象
让我们从 PowerShell 中观察函数
PS >
[NM4.SiteAdmin.Logic.Subscription]::currentSchoolYear
成员类型:方法
重载定义:{静态字符串
currentSchoolYear()} TypeNameOfValue
:
System.Management.Automation.PSMethod
值:静态字符串
currentSchoolYear() 名称
: currentSchoolYear IsInstance
: 是的
为什么哦,为什么?对我来说,这似乎是文档。
【问题讨论】:
标签: .net powershell