Step 1: Identify the issue in the sentence.
The preposition "in" is incorrectly used here. In English, "invited to" is the correct phrase when referring to attending an event.
Step 2: Correct the sentence.
Thus, the correct sentence is: "The gentry of the city was invited to the function."
Final Answer:
\[
\boxed{\text{The gentry of the city was invited to the function.}}
\]