AnsweredAssumed Answered

Setting AttributeParameterValue.ParameterValue results in "Invalid type" exception

Question asked by michael.widmer on Apr 4, 2018
Latest reply on Apr 9, 2018 by mnielsen-esristaff

I'm trying to query a route for pedestrians using the ArcGIS Runtime SDK for .NET 100.2.0 and the ESRI World Routing service.

First I'm retreiving the supported travel modes using the travel modes service using a GeoprocessingTask. I'm about to parse the returned modes to find the "walking" mode, what works fine so far.


When I'm getting to parse and write the AttributeParameterValues for the travel mode object, I'm running into an exception when trying to set the ParameterValue-property of it:

foreach (var attributeValue in modes["attributeParameterValues"])
    string aName = Convert.ToString(attributeValue["attributeName"]);
    string pName = Convert.ToString(attributeValue["parameterName"]);
    string pValue = Convert.ToString(attributeValue["value"]);

    AttributeParameterValue attr = new AttributeParameterValue();
    attr.AttributeName = aName;
    attr.ParameterName = pName;
    attr.ParameterValue = pValue; // <-- here the exception occurs


The value of "pValue" is a simple, unmodified string directly received from the above mentioned travel modes service (that reads e.g. "AVOID_MEDIUM"). Neither setting the value directly works.


I get an exception, stating that the value does not seem to conform to an expected type:

Invalid argument: Invalid element type.

The stacktrace reads as follows:

   bei Esri.ArcGISRuntime.ArcGISException.HandleCoreError(CoreError error, Boolean throwException)
   bei RuntimeCoreNet.GeneratedWrappers.Interop.CheckError(IntPtr errorHandle, Boolean throwOnFailure, GCHandle wrapperHandle)
   bei RuntimeCoreNet.GeneratedWrappers.CoreAttributeParameterValue.set_ParameterValue(CoreElement value)
   bei My.RoutingManager.<SetupTravelModeRouteParameters>d__20.MoveNext() in C:\source\RoutingManager.cs:Line 231.


The exception occurs for all of the various received values targeted to be set. Unfortunately the documentation does not provide any more information (the property itself being declared) about what type of value is expected for that part of the AttributeParameterValue. What kind of type do I need to set for "ParameterValue"?