Hi all How can I create a new/empty ILayerDefinition object?
I used to (MaestroAPI 2) create a new ILayerDefinition by using xml and deserialize and then save the resource (see code below), but in MaestroAPI 4 i get the error: System.NotSupportedException - Cannot serialize interface OSGeo.MapGuide.ObjectModels.LayerDefinition.ILayerDefinition. I cannot do "new ILayerDefinition()" ofcourse but how could I create a new ILayerDefinition object? Is the xml wrong or do I need to do it some other way (IResourceSerrvice.CreateLayerDefinition)? --- code --- string layerDefinition = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<LayerDefinition xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xsi:noNamespaceSchemaLocation=\"LayerDefinition-1.1.0.xsd\" version=\"1.1.0\">" + " <VectorLayerDefinition>" + " <ResourceId />" + " <FeatureName />" + " <FeatureNameType>FeatureClass</FeatureNameType>" + " <Geometry />" + " <VectorScaleRange />" + " </VectorLayerDefinition>" + "</LayerDefinition>"; ILayerDefinition ldef; using (System.IO.MemoryStream ms = new System.IO.MemoryStream(System.Text.Encoding.UTF8.GetBytes(layerDefinition))) ldef = con.ResourceService.DeserializeObject<ILayerDefinition>(ms); string resId = new ResourceIdentifier(Guid.NewGuid().ToString(), ResourceTypes.LayerDefinition, con.SessionID); con.ResourceService.SaveResourceAs(ldef, resId); --- end code --- Regards Hans Milling... -- View this message in context: http://osgeo-org.1560.n6.nabble.com/How-to-create-new-empty-vector-layer-definition-tp4465014p4465014.html Sent from the MapGuide Users mailing list archive at Nabble.com. _______________________________________________ mapguide-users mailing list mapguide-users@lists.osgeo.org http://lists.osgeo.org/mailman/listinfo/mapguide-users