title: DllImport a c++ DLL in to a C# app, BYTE * p
body: <p>I have a exported function in a c++ DLL </p>
  
  <pre><code>// C++ DLL (Blarggg.dll)
  
  extern "C"
  {
       USHORT ReadProperty( BYTE * messsage, USHORT length, BYTE * invokeID ) 
      {
           if( invokeID != NULL ) {
              * invokeID = 10 ; 
          }
           return 0;
      }
  }
  </code></pre>
  
  <p>That I would like to make it available to my C# application </p>
  
  <pre><code>// C# app 
  [DllImport("Blarggg.dll")]
  public static extern System.UInt16 ReadProperty(
          /* [OUT] */ System.Byte[] message,
          /* [IN]  */ System.UInt16 length,
          /* [OUT] */ System.Byte[] invokeID ); 
  
  
  private void DoIt() 
  {
      System.Byte[] message = new System.Byte[2000];
      System.Byte[] InvokeID = new System.Byte[1];
      System.UInt16 ret = ReadProperty( message, 2000, InvokeID ); // Error 
  }
  </code></pre>
  
  <p>The problem is that I keep getting the following error message. </p>
  
  <blockquote>
    <p>An unhanded exception of type 'System.NullReferenceException' occurred in Blarggg.dll
    Additional information: Object reference not set to an instance of an object. </p>
  </blockquote>
  
  <p>I'm using VS2008 to build both the DLL and the C# application. </p>
  
  <p>I'm not a C# programmer. </p>
  
  <p>What am I doing wrong?</p>