FeatureLayer from local FeatureTable: How to avoid exception "data_source is already owned"?

378
1
01-23-2017 06:48 AM
deleted-user-Ohz6rwd1kavx
New Contributor III

Hi,

I'm getting an exception "data_source is already owned" when create a FeatureLayer from a local FeatureTable. In my situation I had already created another FeatureLayer (in another Map) based on the same FeatureTable. I believe this relates to .geodatabase locking.

I have just begun investigating, but I am curious if anyone else is setting this, and more importantly if there are known steps to avoid this.

Thanks,

-Cory 

0 Kudos
1 Reply
deleted-user-Ohz6rwd1kavx
New Contributor III

Here is something that works. I haven't worked out which steps are essential, but it does seem to work.

 

if (MapViewModel.Map != null)

{

MapViewModel.Map.OperationalLayers.Clear();

// just sets Geodatabase references to null

_geodatabaseFactoryService.ReleaseGeodatabases();

GC.Collect();

GC.WaitForPendingFinalizers();

}

0 Kudos