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