SOE - attempted to read or write protected memory error

Discussion created by gbushek on Nov 8, 2012
Latest reply on Nov 14, 2017 by salieghaziz531
I have some arcobjects code that runs fine when running it directly in visual studio. But it fails when I have it running as an SOE.  It fails in a class where I have a call to search a feature class in 2 different locations based on different spatial filter logic.  I've tried setting the map service to both pooled and not pooled but that probably has nothing to do with it as it had no effect. The error is:

"Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at ESRI.ArcGIS.Geodatabase.IFeatureClass.Search(IQueryFilter filter, Boolean Recycling)"

pFC = strSegFC.Search(pSF, True)

Any ideas?