title: It is possible to call a method from a DLL Created in .NET from PERL?
body: <p>I'm using PERL 5.8.8 and I've not found a way to read a PrivateKEY in format pkcs#8 in perl, so I'm trying to create a dll in C# that can do it, so I can call the methods from there.</p>
  
  <p>I see that the module to do this is:</p>
  
  <blockquote>
    <p>Win32::API </p>
  </blockquote>
  
  <p>The example they show is this:</p>
  
  <pre><code>  use Win32::API;
    $function = Win32::API-&gt;new(
        'mydll, 'int sum_integers(int a, int b)',
    );
    $return = $function-&gt;Call(3, 2);
  </code></pre>
  
  <p>The problem is that in the example I can have direct access to the function sum_integers
  but <strong>How can I call my function sum() with this structure from PERL?:</strong></p>
  
  <pre><code>namespace testCreateDLLToUseInPERL
  {
      public class Test
      {
          public Test(){
          }
  
          public int sum(int n1, int n2)
          {
              return n1 + n2;
          }
      }
  }
  </code></pre>
  
  <p>I've tried :</p>
  
  <pre><code> Win32::API::Struct-&gt;typedef( Test =&gt; qw{  });
   Win32::API-&gt;Import('testCreateDLLToUseInPERL', 'Test::sum(int a, int b)');
   my $myObj = Win32::API::Struct-&gt;new('Test');
   print Dumper($myObj );
  </code></pre>
  
  <p>The above code fails with message: </p>
  
  <blockquote>
    <p>the system could not find the environment option that was entered</p>
  </blockquote>
  
  <pre><code>  $function = Win32::API-&gt;new(
        'testCreateDLLToUseInPERL', 'int sum(int a, int b)',
    );
    print Dumper($function);
    print Win32::FormatMessage( Win32::GetLastError() );
    $return = $function-&gt;Call(3, 2);
    print $return;
  </code></pre>
  
  <p>The above code fails with message:  </p>
  
  <blockquote>
    <p>The specified procedure could not be found</p>
  </blockquote>
  
  <p>So, I understand that the DLL was loaded correctly but I've not provided a right path-to-follow to reach that function.</p>
  
  <p>Any ideas?</p>