I'm getting the following intermittent errors related to querying AD using
DirectorySearcher.FindOne()
or FindAll()
.
System.OverflowException: Arithmetic operation resulted in an overflow.
at System.DirectoryServices.SearchResultCollection.ResultsEnumerator.GetCurrentResult()
at System.DirectoryServices.SearchResultCollection.ResultsEnumerator.get_Current()
at System.DirectoryServices.SearchResultCollection.ResultsEnumerator.System.Collections.IEnumerator.get_Current()
This is happening in a web app and seems to happen after the app has been running for several hours.
This is a documented issue on Microsoft Connect but it looks like it has been marked as "not reproducible" and closed.
The only fix that I found here is to recycle the app pool periodically which is a rather harsh workaround and not viable when your users are in the middle of working.
Has anyone experienced this and if so how was this resolved?
I have tried to use caching but this just delays the inevitable until you hit a certain threshold in terms of the number of AD calls since people have reported that each time the API call is made it leaks memory.
Any help would be much appreciated.
See Question&Answers more detail:os