Failing to create a localfeatureservice for editing

2073
4
06-05-2012 03:14 AM
Labels (1)
NirYoscovitz
New Contributor III
Hello,

I get the following exception :
"Failed to create a 'LocalFeatureService' for editing as the service with the same path is already running as an instance of 'LocalMapService' which does not support editing".

It happens in several occasions.
For instance, when I'm instatiating a new editable feature layer after using a QueryTask
or, as shown below, when instatiating a new editable feature layer after instantiating a non-editable layer.


ArcGISLocalFeatureLayer ReadOnlyFeatureLayer = new ArcGISLocalFeatureLayer(@"C:\Data\Map.mpk", 0);
ReadOnlyFeatureLayer.ID = "Streets";
ReadOnlyFeatureLayer.Editable = false;
_mapControl.Layers.Add(ReadOnlyFeatureLayer);

ArcGISLocalFeatureLayer EditableFeatureLayer = new ArcGISLocalFeatureLayer(@"C:\Data\Map.mpk", 1);
EditableFeatureLayer .ID = "Trees";
EditableFeatureLayer .Editable = true;
_mapControl.Layers.Add(EditableFeatureLayer );


What am I doing wrong here ? Can't I use editable and not editable layers on the same mpk ?

I would appreciate your help.
Regards,
Nir
0 Kudos
4 Replies
MichaelBranscomb
Esri Frequent Contributor
Hi,

The local feature service which supports the ArcGISLocalFeatureLayer is started as either editable or non-editable - this property cannot be changed after the service is started. However, as the developer of the application it is up to you which layers you expose as editable to the user.

Cheers

Mike
0 Kudos
NirYoscovitz
New Contributor III
Hi Mike,

Thank you for your answer.

How can I set the local feature service to be editable ?

Nir
0 Kudos
NirYoscovitz
New Contributor III
Eventually I have managed to workaround this issue by using 2 MPKs - one Read only and one editable.
I hope future releases of the Runtime will allow using one single mpk in both modes and dismiss the need of mpk duplication.

Regards,
Nir
0 Kudos
MichaelBranscomb
Esri Frequent Contributor
Hi,

The duplication is not necessary - you can just use the one Map Package and from that MPK create a Feature Service. All layers in the feature service will technically be editable but it's up to you as the developer which layers you allow your users to actually edit.

For finer grained control over services you could look at the LocalFeatureService class.

Cheers

Mike
0 Kudos