IFeature.Shape throws an error

Discussion created by odoe on Apr 21, 2011
Latest reply on Oct 17, 2013 by prashant.dhuri
I don't usually need to deal with geometries too often in ArcObjects, but this is giving me quite a hard time.

I can get a IFeature object from my SDE. I can access the attributes fields just fine and pass them as needed. The problem is, when I try to access the IFeature.Shape property, I get the following error.
Error HRESULT E_FAIL has been returned from a call to a COM component.

at ESRI.ArcGIS.Geodatabase.IFeature.get_Shape()

This is a code snippet below.
Type sde_type = Type.GetTypeFromProgID("esriDataSourcesGDB.SdeWorkspaceFactory");
//IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)new SdeWorkspaceFactoryClass();

IWorkspaceFactory workspaceFactory = (IWorkspaceFactory)Activator.CreateInstance(sde_type);
IWorkspace workSpace = workspaceFactory.Open(propertySet, 0);
IFeatureWorkspace featureWorkspace = (IFeatureWorkspace)workSpace;

IFeatureClass featureClass = featureWorkspace.OpenFeatureClass("sde.LA_Parcels");

// prepare the query filter
IQueryFilter qf = new QueryFilterClass();
qf.SubFields = "AIN";
qf.WhereClause = "AIN = '" + ain + "'";

IFeatureCursor fc = featureClass.Search(qf, true);

IFeature feat = fc.NextFeature();
string s_ain = "NOT FOUND";
if (feat != null)
 int field = feat.Fields.FindField("AIN");
 s_ain = feat.get_Value(field) as string;
 // grab some more field data ...
 IGeometry fgeom = null;
  fgeom = feat.Shape; // error gets thrown here
 catch (Exception e)
  throw new Exception(String.Format("ParcelLocationData Geometry from Shape Error: {0}", e.Message), e);

I had read on a blog that it was good practice when creating ArcObjects objects on server to not use "new", but use Activator.CreateInstance, so I switched that up as it came up in my search on the COM error, but still nothing works.

I can view this data in ArcMap just fine, it works on MapServices that we have.
I have other C# dll's using ArcObjects running on this server just fine for sewer tracing, none of which actually access the IFeature.Shape property though.

Is there a step I am missing to try and do this?
My goal here is to use the IFeature.Shape as a basis for some spatial queries on other features.
Something like this
IArea area = (IArea)fgeom;
spatialFilter.Geometry = area.Centroid

Thanks in advance, and I'm sorry if this is something simple I am missing.