paulorfmmb has asked for the wisdom of the Perl Monks concerning the following question:

Need your help Monks,

I'm trying to pass a array to a .NET DLL. I created a COM object with my DLL using 392275. But I when I try to pass an array to my function I get this response:

Win32::OLE(0.1712) error 0x8002000e: Number of parameters invalid in METHOD/PROPERTYGET "Test"

Here is my Perl code:

use Win32::OLE; $hl = new Win32::OLE('TestDot.myClass') or die $!; my @ptrObject = (5, 10, 10); my $ret = $hl->Test(@prtObject); print(Win32::OLE->LastError()."\n");

Here my .NET function:

namespace TestDot { public unsafe class myClass { public int Test(int *ptr) { return ptr[1]; } } }

Replies are listed 'Best First'.
Re: Passing a pointer to a .NET DLL
by syphilis (Archbishop) on May 10, 2018 at 14:34 UTC
    Here is my Perl code

    Your code references 2 different arrays - @ptrObject and @prtObjetc.

    Cheers,
    Rob
      That is just a typo in here.
        ... just a typo ...

        That's why use of an Short, Self-Contained, Correct Example can be so important when asking a question:

        1. Here's the exact code I'm running;
        2. Here's the exact input data;
        3. Here's the output I get;
        4. Here's the output I want;
        5. Why don't I get what I want?

        See also the Test::More approach to presenting code and input/output.


        Give a man a fish:  <%-{-{-{-<

Re: Passing a pointer to a .NET DLL
by stevieb (Canon) on May 10, 2018 at 14:21 UTC

    Looks to me as though the C# method expects one parameter but you're sending in three.

    That said, I am not familiar with Win32::OLE, so I'm unsure if that module sends a pointer to the array to the method (doesn't appear that way though).

      In other words, what happens if you pass \@prtObject rather than @prtObject?

        I get this response:

        Win32::OLE(0.1712) error: 0x80070057: "Incorrect parameter" in METHOD/PROPERTYGET "Test"

Re: Passing a pointer to a .NET DLL ( Win32::OLE::Variant?)
by beech (Parson) on May 10, 2018 at 21:09 UTC