Select to view content in your preferred language

ArcGIS Pro Unable to load Feature datset into Map

493
1
01-02-2018 03:31 PM
RichardDaniels
Regular Contributor

In a C# Add-In I can add a SDE style feature class to my map with the following code, this fails when attempting to load a FC contained in a Feature Dataset.

case "SDEFeature":

uri= new Uri(theFullPath.Replace(theSeperator,@"\"));

t = QueuedTask.Run(() =>

{

try

{

var x = LayerFactory.Instance.CreateLayer(uri, mapView.Map, 0, theShortName);

}

catch (Exception eX)

{

MessageBox.Show("Unable to load the selected dataset. " + eX.Message.ToString(), "Data Load Problem", MessageBoxButtons.OK);

}

});

In the above example theSeperator used in the source is "|".

When using a feature dataset it returns "Unable to load the selected dataset. Failed to create layer from W:\HQsdePoliticalAdminBoundariesP.sde\PoliticalAminBoundaries.DBO.CadastrialFWCountyBndr."

Question, is there a difference when specifying a Feature Class vs. Feature Dataset when using the layer factor? Should I be using a different factory?

0 Kudos
1 Reply
RichardDaniels
Regular Contributor

Found the issue. In ArcMap when loading a feature class contained in a feature dataset you could actually IGNORE the dataset name when building your path. In ArcGIS Pro they required the dataset name (as should have been done in ArcMap). In addition there is a feature class factory that can be used to build your connection in Pro.

LayerFactory.Instance.CreateFeatureLayer(uri, mapView.Map, 0, theShortName);

Easy solutions is to create a layer file that contains the sde connection information vs. trying to connect directly.

In Pro the path formats are:

* string url = @"c:\data\project.gdb\DEM"; //Raster dataset from a FileGeodatabase

* string url = @"c:\connections\mySDEConnection.sde\roads"; //FeatureClass of a SDE

* string url = @"c:\connections\mySDEConnection.sde\States\roads"; //FeatureClass within a FeatureDataset from a SDE <-- what I'm doing

* string url = @"c:\data\roads.shp"; //Shapefile

* string url = @"c:\data\imagery.tif"; //Image from a file

* string url = @"c:\data\mySDEConnection.sde\roads"; //.lyrx or .lpkx file

0 Kudos