If it's a shape file feature layer, please make sure you open the layer by ReadOnly mode.
ShapeFileFeatureLayer imActualRouteLayer = new ShapeFileFeatureLayer(sourceShapeFile, ShapeFileReadWriteMode.ReadOnly);
Because your website will be access by multiply user at same time, if you modify the features when you try to query it, this exception will be thrown, that's because it contains foreach logic.
So if it's an inMemoryFeatureLayer, and you have to modify its feature, please lock it when you modify it, or you can copy the layer, then query in the copied one.
Wish that's helpful.