[Mono-list] How do you debug?

Ivan Hawkes blackhawk@ivanhawkes.com
Fri, 4 Jul 2003 17:47:45 +0100


=2D----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Friday 04 Jul 2003 4:40 pm, Marco Canini wrote:
> > Unhandled Exception: System.InvalidCastException: Cannot cast from sour=
ce
> > type to destination type
> > in <0x0007a> 00 System.Data.SqlClient.SqlDataReader:GetInt32 (int)
> > in <0x00189> 00 Interesource.Publish.Client.ContentList:.ctor
> > (System.Data.IDataReader,bool)
> > in <0x00012> 00 Interesource.Publish.Client.ContentList:.ctor
> > (System.Data.IDataReader)
> > in <0x000a2> 00
> > Interesource.Publish.Client.ContentProvider:ListContentItems
> > (Interesource.Publish.Entities.ContentTypeKey)
> > in <0x0009e> 00 simpletest.SimpleTest:Main (string[])
>
> this could be a different type mapping between mono's SqlClient and
> .net's SqlClient
>
> Could you report the table definition (sql), the datacolumn definition,
> and the code that raises the exception.

Ok, it definitely looks like Mono being a little naughty but it's a simple=
=20
fix.

The offending code is:

uniqueId =3D reader.GetInt32(reader.GetOrdinal("RealContentItemId"));


and the fix is:

uniqueId =3D reader.GetOrdinal("RealContentItemId");

It seems that GetOrdinal is returning an Int32 and we then try to convert t=
o a=20
(wait for it) Int32. Mono should just ignore this code but it doesn't.=20
Actually, the programming team never should have written it like this, but=
=20
hey, Mono should handle this kind of stupidity.
=2D----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)

iQIVAwUBPwWvsfr1e7bH1pzBAQJK4Q/+NlxVCzx8zaE4iGOcRm46hMn1WDh3o13y
4JKlrV3V3ejspE3xBtdmE3s7MYTzbTzUeS39fUJycg+CcivGBA5ibkkPj7VR1nn7
8+ZZj1UHM6n4weK2A+1GK2iCQmooBy3HrYzWEkKY5nXDfJSkVLkaj0r0DhQjh756
5SWrRlN2sUIlD+raqRrTg4Mixxr1KUDtx7biJ2L3p7CzjwZqFGc3Q44rVNjX/yMq
NuWdalTEwzYIqvLkiW8VCGSE0C6KXFavmMNRetZ3PHZl+6R+iFbUOWylmpYg419l
3Br0E1nkdtODzS3DPqK/OWytqF8R9MOZ5uLOGMYEL2kBizbjzYkTWv7eb4WY6ftH
LeC4lZMZbp6E9jbUe4ucEj9q6lO8TT1plpm8diS1taDc6MJpg6TrzHagcMVm50bk
48T9vF7TtIyfbpVwXPr2ZfnTW+WHNWtB3HyZKu/fOsdLP00STSh2jzVpQgxOEsKc
sPbiUH4nlLAC8EtNuRNVcWyT4qjCt/mMbDYVCMVlJm2TlbWSfKKOto1f4c4JtQ/G
X1kFDdVzZoA/JPOY26GY4olx57NEFDsz0vmputVasoXNtxnba3/ufFUazIKa7Hy0
jw+75G4CLTO66Fh808Vd784gH1XRBfR6bfFJYJso6KYCkzTSdMuw0GtrCJsTF21+
DIt/h4YSu/o=3D
=3DQ+Z5
=2D----END PGP SIGNATURE-----