The maximum limit for the length of the QueryText property of FullTextSqlQuery is 4096 characters.

Requirement:

  • I was working on case, where Customer's business requirement was to have the length of the QueryText property of FullTextSqlQuery to be UNLIMITED.

Troubleshooting:

  1. Moment the code touches the limit of about 4093 it throws the error
  2. Error: Specified argument was out of range of valid values; _COMPlusExceptionCode -532459699
  3. Occurs When: Error comes when trying to assign the string value to the QueryText property itself.
  4. Took help from our Escalation engineer Nishandv, to know the exact hard-code limit (if any) in SharePoint for QueryText property of FullTextSqlQuery object

Resolution / WorkAround:

  • When using FullTextSqlQuery objects for search; make sure the length of the QueryText Property do not exceed 4096 characters

Reference :