title: Managed Type equivalent of [MarshalAs(UnmanagedType.I8)]
body: <p>I have inherited a dll written in C that I access from a windows application (Framework 2.0) in C#. Recently some machines have been upgraded to 64-bit Windows 7, and the dll is no longer returning the correct values on those machines. I believe this is because the C function has parameter types that are expected to be 64-bit.</p>
  
  <p>Here's the signature of the C function</p>
  
  <pre><code>int doFlightCalc_S(double LatA, 
                     double LonA, 
                     double LatB, 
                     double LonB, 
                     int month, 
                     int aircraftCd, 
                     int nbrPsgrs, 
                     int taxiInTm, 
                     int taxiOutTm, 
                     int fuelStopTime, 
                     int *results)
  </code></pre>
  
  <p>Here's the definition that accesses the function from C#</p>
  
  <pre><code>[DllImport("doFlightCalc.dll", CallingConvention = CallingConvention.Cdecl)]
          private static extern int doFlightCalc_S(
               [MarshalAs(UnmanagedType.R8)] double latA,
               [MarshalAs(UnmanagedType.R8)] double lonA,
               [MarshalAs(UnmanagedType.R8)] double latB,
               [MarshalAs(UnmanagedType.R8)] double lonB,
               [MarshalAs(UnmanagedType.I4)] int month,
               [MarshalAs(UnmanagedType.I4)] int aircraftCd,
               [MarshalAs(UnmanagedType.I4)] int nbrPsgrs,
               [MarshalAs(UnmanagedType.I4)] int taxiInTm,
               [MarshalAs(UnmanagedType.I4)] int taxiOutTm,
               [MarshalAs(UnmanagedType.I4)] int fuelStopTime,
              [MarshalAs(UnmanagedType.LPArray)] [Out] int[] results);
  </code></pre>
  
  <p>If I were to compile the C dll as a 64-bit dll while leaving the function as is, what changes would I need to make to the function in C#?</p>
  
  <p>I would assume that I have to change the I4s to I8s but what type would I replace the int and double with? Would the following :</p>
  
  <pre><code>             [MarshalAs(UnmanagedType.R8)] double lonB,
               [MarshalAs(UnmanagedType.I4)] int month,
  </code></pre>
  
  <p>be changed to:</p>
  
  <pre><code>             [MarshalAs(UnmanagedType.R8)] (what would go here?) lonB,
               [MarshalAs(UnmanagedType.I8)] long (is long correct here?) month,
  </code></pre>
  
  <p>Or am I barking up the wrong tree?</p>