On the PgSqlCommand.ExecuteScalar() docs page there is an error:
It says: CommandText = "select count(*) as NumberOfRegions from region"; int count = (int) ExecuteScalar();
The conversion does not work in .NET1.1, the result of count() aggregate is int8 type, so it should be Int64 instead of int.