HRESULT E_FAIL has been returned from a call to a COM component.

1497
1
07-07-2012 01:04 PM
InsuHong1
New Contributor
Hello,

I suffer from error  HRESULT E_FAIL has been returned from a call to a COM component in .Net.

I developed code that work through large dataset iteratively. It repeats almost same function for each iteration.

But in the middle of iteration, I meet  HRESULT E_FAIL has been returned from a call to a COM component.

The point of error looks random.

Sometimes it crashes here, next time in there.

It crashes at such as

                    fc2Poly.in_features = inBoundary + ";" + pairline;
                    fc2Poly.out_feature_class = "polyMerged";
                    gp.Execute(fc2Poly, null);

or


fcOuterBarriers = gpUtils.OpenFeatureClassFromString("polyMerged_erased");




Error occurs at data open or writing, so I think it could be problem with GDB that I use for process.

Each iteration, I make several temporary featureclass files at GDB, and overwrite those in next iteration.

Is it possible overwriting repeatedly cause problem of GDB?



Please help me.



Thnks.


Insu
0 Kudos
1 Reply
DuncanHornby
MVP Notable Contributor
Is the error occurring because you are running out of memory? Open Task Manager and see memory usage this is creeping up to the point it crashes. If it is then I'm guessing you need to release your cursors correctly to release the memory.

I now use the ComReleaser in just about all code I write now. See example code below:

' For ArcGIS 10 using VS 2010 you need to import the following
Imports ESRI.ArcGIS.ADF.Connection.Local
Imports ESRI.ArcGIS.ADF
 Dim pQueryFilter As IQueryFilter 
pQueryFilter= New QueryFilterClass
pQueryFilter.WhereClause = "ID = 1"
Using releaser As New ComReleaser 
Dim pFeatureCursor As IFeatureCursor 
pFeatureCursor = pFeatureclass.Update(pQueryFilter, True) 
releaser.ManageLifetime(pFeatureCursor) 
Dim pFeature As IFeature 
pFeature = pFeatureCursor.NextFeature 
While pFeature IsNot Nothing 
' Do something with pFeature 
pFeatureCursor.UpdateFeature(pFeature) 
pFeature = pFeatureCursor.NextFeature 
End While
End Using


Duncan
0 Kudos