I'm trying to call this really simple .NET 4 function with PowerShell v2. Its definition look like:
Public Shared Function currentSchoolYear() As String Member of NM4.SiteAdmin.Logic.Subscription
Let's add the path to the DLL file containing that function. It's an ASP.NET MVC web application DLL file.
PS > Add-Type -Path C:\xxx\bin\xxxWebApp.dll
Let's try it (FAIL!):
PS >
[NM4.SiteAdmin.Logic.Subscription]::currentSchoolYear()
Exception calling "currentSchoolYear"
with "0" argument(s): "The type
initializer for
'NM4.SiteAdmin.Logic.Subscription'
threw an exception." At line:1 char:54
+ [NM4.SiteAdmin.Logic.Subscription]::currentSchoolYear
<<<< ()
+ CategoryInfo : NotSpecified: (:) [],
MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Let's observe the class from PowerShell:
PS >
[NM4.SiteAdmin.Logic.Subscription]
IsPublic IsSerial Name
BaseType
-------- -------- ---- -------- True False Subscription
System.Object
Let's observe the function from PowerShell
PS >
[NM4.SiteAdmin.Logic.Subscription]::currentSchoolYear
MemberType : Method
OverloadDefinitions : {static string
currentSchoolYear()} TypeNameOfValue
:
System.Management.Automation.PSMethod
Value : static string
currentSchoolYear() Name
: currentSchoolYear IsInstance
: True
Why oh why? It seems like the doc to me.