AnsweredAssumed Answered

"Failed to create service essai MapServer. Service failed to initialize: Feature service creation failed. hr=0x80040067 No Layer or Table was initialized

Question asked by ManelKeddar on Jun 16, 2017

Hello every one ,

 

Need help , i'm having this error and i'm trying to access to a feature table named essai of my geodatabase named Test so i ve athored a .mpk file and i'm trying to access to this file so i can add on it a geometry so i used the local server and local services here's my code :

private Esri.ArcGISRuntime.LocalServices.LocalServer _localServer;

private async void StartLocalServer()
{
//get the singleton LocalServer object using the static instance property
_localServer = Esri.ArcGISRuntime.LocalServices.LocalServer.Instance;

//Handle the statusChanged event to react when the server is started

_localServer.StatusChanged += ServerStatusChanged;

//Start the local server instance

await _localServer.StartAsync();

}

private async void ServerStatusChanged(object sender , Esri.ArcGISRuntime.LocalServices.StatusChangedEventArgs e)
{

//Check if the server started successfully
if(e.Status == Esri.ArcGISRuntime.LocalServices.LocalServerStatus.Started)
{
//Create a local feature service from a map package on disk

LocalFeatureService featureService = new LocalFeatureService(@"C:\Users\mkeddar\Documents\ArcGIS\essai.mpk");

//Handle the status changed event to check when it's loaded

featureService.StatusChanged += async (svc, args) =>
{
//If started successfully , add a layer from the service
if (args.Status == LocalServerStatus.Started)
{
//Get the service URL
var featureServiceUrl = (svc as LocalFeatureService).Url.AbsoluteUri;
//Create a new service feature table
ServiceFeatureTable localServiceTable = new ServiceFeatureTable(new Uri(featureServiceUrl + "/2"));

//Create a new feature layer to display the features in the table
FeatureLayer featureLyr = new FeatureLayer(localServiceTable);

var attribute = new Dictionary<String, object>();
attribute.Add("description", "description");

var geomCone = createCone3D();

//create a new feature
var newFeature = localServiceTable.CreateFeature(attribute,geomCone); // here i don't know what to guive as parameters so i create a feature
//from my geometry geomCone
//add the new feature
await localServiceTable.AddFeatureAsync(newFeature);
//push this update (apply edits) to the feature service

IReadOnlyList<EditResult> editResults = await localServiceTable.ApplyEditsAsync();
//check the results for errors

foreach(var r in editResults)
{
if (r.CompletedWithErrors)
{
Console.WriteLine("Edit ti Object" + "'failed'" + r.Error.Message);
}
}


}


};

 

//Start the local feature service
await featureService.StartAsync();

i don't know where's the problem any one can help me please thanks in advance

Outcomes