'out' keyword in methodes param

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • [Yosi]

    'out' keyword in methodes param

    I have the following dll function:
    RW_DLL_API int ReadBDll(DWORD Address, DWORD NumOfUnits, BYTE * val)

    From my C# application I call this one as following :

    [DllImport("RW_D LL.dll")]
    extern static int ReadBDll(UInt32 Address, UInt32 NumOfUnits, out byte [] Block);
    byte [] arr = new byte[5];
    int i = ReadBDll(0x2e,1 , 5,out arr );
    but after execution the function I got the following 'arr' value = <Undefined value> why ??????????????? ??????
  • Mattias Sjögren

    #2
    Re: 'out' keyword in methodes param


    Just remove the out keyword and it should work better.



    Mattias

    --
    Mattias Sjögren [MVP] mattias @ mvps.org
    http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
    Please reply only to the newsgroup.

    Comment

    • Jon Skeet [C# MVP]

      #3
      Re: 'out' keyword in methodes param

      [Yosi] <Yosi@discussio ns.microsoft.co m> wrote:[color=blue]
      > I have the following dll function:
      > RW_DLL_API int ReadBDll(DWORD Address, DWORD NumOfUnits, BYTE * val)
      >
      > From my C# application I call this one as following :
      >
      > [DllImport("RW_D LL.dll")]
      > extern static int ReadBDll(UInt32 Address, UInt32 NumOfUnits, out byte [] Block);
      > byte [] arr = new byte[5];
      > int i = ReadBDll(0x2e,1 , 5,out arr );
      > but after execution the function I got the following 'arr' value =
      > <Undefined value> why ??????????????? ??????[/color]

      I suspect that the method has effectively set the value to null
      somewhere.

      --
      Jon Skeet - <skeet@pobox.co m>
      Pobox has been discontinued as a separate service, and all existing customers moved to the Fastmail platform.

      If replying to the group, please do not mail me too

      Comment

      Working...