V8i C# Select Series 2 - Microstation crashes when trying to Query features with in a fence

All,

I have used the following code to query features with in a fence

BGU.IImportCriteria criteria;
BGU.IStorageImportCriteria storageImp;criteria = GDI.GeoDataInterchangeAddIn.Instance.MasterFileImport;
if (criteria == null) return;// Set spatial filter criteria. criteria.Geometry = null;// Set Spatial Area Criteriacriteria.SpatialArea = BGU.SpatialArea.Fence;storageImp = criteria.StorageImports[0] as BGU.IStorageImportCriteria;
if (storageImp == null)
 return;
BGU.IClassImportCriteria classImp = storageImp.ClassImports as BGU.IClassImportCriteria;if (classImp != null)
 classImp.Selected = true; 
GDI.GeoDataInterchangeAddIn.Instance.ImportOrExport(criteria, null, true, true);

In most cases this code works fine but in some projects it is giving me error at the following line

// Execute the query.
GDI.GeoDataInterchangeAddIn.Instance.ImportOrExport(criteria, null, true, true);

This is the exception

"An unhandled exception of type 'System.stackoverflowException' occured in Bentley.EngineeringContent.Storage.xfm.dll

As this is Stackoverflow exception I cannot handle it from c# code. I just need some help to analyze this error, does this happen If i try to query in more features or is this related to some other issues.

I really appreciate your time and help