AnsweredAssumed Answered

.Net Runtime 100.2 Unable to Create Attributes with an Object

Question asked by FDM_Jim on Apr 17, 2018
Latest reply on Apr 17, 2018 by FDM_Jim

In 10.2.7 I was able to create a Graphic object and assign attributes to it. Now at 100.2 the same code doesn't work and I've tried multiple ways to resolve the problem:

  1. Create a Graphic with a constructor containing an Attribute dictionary
  2. Create a Graphic and assign the attributes after the fact

 

The breaking point seems to be the assignment of an object and if I omit the object the Attributes \ Graphic can be created. I need some input on this. Below is my code examples of what doesn't work:

 

Failing Example #1

 

//create a basic map details item object to pass in
var mapDetails = new MapDetailsItem
{
Id = dataItem.Id.NativeValue, //this is an int
ProfileId = dataItem.ProfileId.NativeValue, //this is an int
HasLayout = dataItem.HasLayout //this is an bool
};

 

var location = new Esri.ArcGISRuntime.Geometry.MapPoint(dataItem.Longitude, dataItem.Latitude, new SpatialReference(SpatialReferences.Wgs84.Wkid));

Graphic result = new Graphic(location);

if (result != null)
{
result.Attributes["ID"] = dataItem.Id.NativeValue;
result.Attributes["Description"] = dataItem.Description;
result.Attributes["MapDetailsItem"] = mapDetails; //this item will break and throw an exception
}

 

Failing Example #2

//create a basic map details item object to pass in
var mapDetails = new MapDetailsItem
{
Id = dataItem.Id.NativeValue,
ProfileId = dataItem.ProfileId.NativeValue,
HasLayout = dataItem.HasLayout
};

var graphicAttributes = new Dictionary<string, object>
{
{"ID", dataItem.Id.NativeValue},
{"Description", dataItem.Description},
{"MapDetailsItem", mapDetails}
};

 

var location = new Esri.ArcGISRuntime.Geometry.MapPoint(dataItem.Longitude, dataItem.Latitude, new SpatialReference(SpatialReferences.Wgs84.Wkid));

Graphic result = new Graphic(location,graphicAttributes);

 

Here is the error which I receive:

Outcomes