title: C# PInvoke VerQueryValue returns back OutOfMemoryException?
body: <p>Below is the code sample which I got from online resource but it's suppose to work with fullframework, but when I try to build it using C# smart device, it throws exception saying it's out of memory.  Does anybody know how can I fix it to use on compact?  the out of memory exception when I make the second call to VerQueryValue which is the last one.</p>
  
  <p>thanks,</p>
  
  <pre><code>    [DllImport("coredll.dll")]
      public static extern bool VerQueryValue(byte[] buffer, string subblock, out IntPtr blockbuffer, out uint len);
  
      [DllImport("coredll.dll")]
      public static extern bool VerQueryValue(byte[] pBlock, string pSubBlock, out string pValue, out uint len);    
      //
      private static void GetAssemblyVersion()
      {
  
          string filename = @"\Windows\MyLibrary.dll";
          if (File.Exists(filename))
          {
              try                {
  
                  int handle = 0;
                  Int32 size = 0;
                  size = GetFileVersionInfoSize(filename, out handle);
  
                  if (size &gt; 0)
                  {
                      bool retValue;
                      byte[] buffer = new byte[size];
                      retValue = GetFileVersionInfo(filename, handle, size, buffer);
                      if (retValue == true)
                      {
                          bool success = false;
                          IntPtr blockbuffer = IntPtr.Zero;
                          uint len = 0;
                          //success = VerQueryValue(buffer, "\\", out blockbuffer, out len);
                          success = VerQueryValue(buffer, @"\VarFileInfo\Translation", out blockbuffer, out len);
  
                          if(success)
                          {
                              int p = (int)blockbuffer;
  
                              //Reads a 16-bit signed integer from unmanaged memory
                              int j = Marshal.ReadInt16((IntPtr)p);
                              p += 2;
  
                              //Reads a 16-bit signed integer from unmanaged memory
                              int k = Marshal.ReadInt16((IntPtr)p);
  
                              string sb = string.Format("{0:X4}{1:X4}", j, k);
                              string spv = @"\StringFileInfo\" + sb + @"\ProductVersion";
  
                              string versionInfo;
                              VerQueryValue(buffer, spv, out versionInfo, out len);
                          }    
                      }
                  }
              }
              catch (Exception err)
              {
                  string error = err.Message;
              }
          }
      }
  </code></pre>