[Mono-list] Possible P/Invoke bug found in ODBC.NET

Dietmar Maurer dietmar@ximian.com
16 Oct 2002 19:42:47 +0200


Hi Brian,

please can you provide a small test case to reproduce the bug? I already
looked at the jit code but cant find the bug. So a small test case to
reproduce it would be very helpful.

- Dietmar

On Wed, 2002-10-16 at 06:11, Brian Ritchie wrote:
> I've run across what looks to be a bug with P/Invoke in mono...
> 
> In the ODBC.NET provider, I've declared a reference to an external dll as 
> follows...
> 
> [DllImport("odbc32.dll")]
> public static extern OdbcReturn SQLDescribeCol(IntPtr StatementHandle, 
> ushort ColumnNumber, byte[] ColumnName, short BufferLength, ref short 
> NameLength, ref OdbcType DataType, ref short ColumnSize, ref short 
> DecimalDigits, ref short Nullable);
> 
> The OdbcType is an enumeration declared as:
> 
> public enum OdbcType : short
> {
>     BigInt=-5,
>     Binary=-2,
>     ...
> }
> 
> This call works fine under ms.net...and the DataType parameter is returned 
> correctly.  However, when run through mono on windows...it return 0.  It 
> looks like mono isn't using the declared type of the enumeration: short.
> 
> I modified the code as follows...and it works in mono and ms.net...
> 
> [DllImport("odbc32.dll")]
> public static extern OdbcReturn SQLDescribeCol(IntPtr StatementHandle, 
> ushort ColumnNumber, byte[] ColumnName, short BufferLength, ref short 
> NameLength, ref short DataType, ref short ColumnSize, ref short 
> DecimalDigits, ref short Nullable);
> 
> Could someone on the runtime side take a look at this?
> 
> Thanks,
> Brian
> 
> BTW...
> 
> I've checked in the alternate Dllimport declaration for the ODBC.NET 
> provider so it will work in Mono.
> Daniel, this should fix the problem you report to me today.
> 
> 
> 
> 
> 
> 
> _________________________________________________________________
> Protect your PC - get McAfee.com VirusScan Online 
> http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
> 
> 
> _______________________________________________
> Mono-list maillist  -  Mono-list@ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list