AnsweredAssumed Answered

Can't release layer lock on geodatabase

Question asked by kbmeinstein on Dec 17, 2019
Latest reply on Dec 30, 2019 by kbmeinstein

I'm creating a new layer in a map using LayerFactory.Instance.CreateFeatureLayer with an existing layer file previously created with ArcGIS 10.5.1 (i.e., .lyr, .lyrx).  Once this new layer is created, since I know it's data link is broken I change it's data source to a different data source that contains the appropriate data.  This all works fine.  The problem is that when I change the layer's data source, it puts a lock on the entire geodatabase containing the data and now I can't write anything else to the geodatabase.  Even if I close the map containing the layer, the lock remains until I close Pro. Does anyone have any ideas how to release the lock?  Any help would be greatly appreciated.


Here's my code:


Layer newlayer = LayerFactory.Instance.CreateFeatureLayer(symbologyUri, MyMap, LayerPosition.AddToTop);


CIMStandardDataConnection newDataConnection = new CIMStandardDataConnection()
WorkspaceConnectionString = workspaceConnectionStringForNewData,
WorkspaceFactory = WorkspaceFactory.FileGDB,
Dataset = datasetName,
DatasetType = esriDatasetType.esriDTFeatureClass

newlayer.SetDataConnection(newDataConnection);  //This is where the lock occurs