The PageMethods Returned an System.InvalidOperationException while I was returning a dataset. It was interesting to note that the probem only occured whin i was trying to return more data.
I was using the code to populate the city when a user selects a state from a drop down list. Ideally a cascading country , state, city cascading drop down list.
I figured out that the data has problem only if the number of cities in the state was higher.
Probem was solved by removing maxJsonLength from the jsonSerialization tag.
Please donot forget to uncomment the jasonserialiation in case you want to return a dataset in pagemethods