obj.id = Convert.ToInt32(idCollection.Count);
The Convert.ToInt32 is unnecessary since the Count property of the StringCollection, or any collection, is already an integer.
You need to narrow it down a bit, what is the exception that is being thrown?