title: BadImageFormatException
body: <p>i was working with invoking C++ Dlls into C# and ran into a problem</p>
  
  <p>C++ function:</p>
  
  <pre><code>    int _declspec(dllexport) CompressPacket(unsigned char *buff, int offset, int len);
  </code></pre>
  
  <p>C# function:</p>
  
  <pre><code>    [DllImport("HuffCompress.dll")]
              private static extern unsafe int HuffCompress(ref byte[] buff, int offset, int len);
  
      ...
  
      private unsafe byte[] CompressPacket(byte[] packet)
      {
          int len = HuffCompress(ref packet, 12, packet.Length-12);
          byte[] compressed = new byte[len];
          for (int i = 0; i &lt; len; i++)
              compressed[i] = packet[i];
          return compressed;
      }
  </code></pre>
  
  <p>when</p>
  
  <p><code>int len = HuffCompress(ref packet, 12, packet.Length-12);</code></p>
  
  <p>is run, i get a BadImageFormatException</p>
  
  <p>As the C# editor is the VSC# Express, it doesn't compile 64 bit programs, so i'm unsure to the problem
  Any ideas would be great</p>