Mapx File loading into CIMMapDocument object error

165
3
06-24-2021 06:43 PM
ThanHtetAung_EsriAu
Esri Regular Contributor

Hi Guys,

I am loading mapx file into CIMMapDocument object by using below code snippet,

In some document I got the error message "Value was either too large or too small for an Int32."

I added the stacktrace for detail as well. Can you guys suggest how to solve it? @Wolf 

Prosdk version is 2.7, 

string mapxJson = File.ReadAllText(mapxFilePath);
bool success = await QueuedTask.Run(() =>
            {
                try
                {
                    CIMMapDocument mapDoc = CIMMapDocument.FromJson(mapxJson);
                    if (mapDoc.LayerDefinitions != null && mapDoc.LayerDefinitions.Length > 0)
                    {
                        this.SourceDocument = mapDoc;
                       
                        return true;
                    }
                }catch(Exception ex)
                {
System.Diagnostics.Trace.WriteLine(ex.Message + "\r\n" + ex.StackTrace);
                    return false;
                }
                return false;
            });

 

StackTrace is

at System.Convert.ToInt32(Int64 value)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at Newtonsoft.Json.Linq.Extensions.Convert[T,U](T token)
at ArcGIS.Core.CIM.JsonUtils.GetObjectForPropertySetOrArray(JToken jToken, JsonDeserializationSettings settings)
at ArcGIS.Core.CIM.JsonUtils.TrySetDictionaryMember(JObject jObject, String memberName, Dictionary`2& dictionaryMember, JsonDeserializationSettings settings)
at ArcGIS.Core.CIM.CIMBasicFeatureTemplate.Deserialize(JObject jObject, JsonDeserializationSettings settings)
at ArcGIS.Core.CIM.JsonUtils.DeserializeCIMObject(JObject jObject, JsonDeserializationSettings settings)
at ArcGIS.Core.CIM.JsonUtils.DeserializeCIMObject[T](JObject jObject, JsonDeserializationSettings settings)
at ArcGIS.Core.CIM.JObjectExtensions.TryGetCIMObjectArrayMember[T](JObject jObject, String memberName, JsonDeserializationSettings settings)
at ArcGIS.Core.CIM.CIMBasicFeatureLayer.Deserialize(JObject jObject, JsonDeserializationSettings settings)
at ArcGIS.Core.CIM.CIMGeoFeatureLayerBase.Deserialize(JObject jObject, JsonDeserializationSettings settings)
at ArcGIS.Core.CIM.JsonUtils.DeserializeCIMObject(JObject jObject, JsonDeserializationSettings settings)
at ArcGIS.Core.CIM.JsonUtils.DeserializeCIMObject[T](JObject jObject, JsonDeserializationSettings settings)
at ArcGIS.Core.CIM.JObjectExtensions.TryGetCIMObjectArrayMember[T](JObject jObject, String memberName, JsonDeserializationSettings settings)
at ArcGIS.Core.CIM.CIMMapDocument.Deserialize(JObject jObject, JsonDeserializationSettings settings)
at ArcGIS.Core.CIM.JsonUtils.FromJson[T](String json, JsonDeserializationSettings settings)
at Tools.UI.DockpaneSetDataSourceViewModel.<>c__DisplayClass168_0.<GetMapxDataSourceInfo>b__0() in D:\protoolset\tools\dockpanesetdatasourceviewmodel.cs

0 Kudos
3 Replies
Wolf
by Esri Regular Contributor
Esri Regular Contributor

If you use ArcGIS Pro to load the file (from path) does that work?

0 Kudos
Wolf
by Esri Regular Contributor
Esri Regular Contributor

I tried your code snippet and it worked fine with my sample mapx files.  It might be a specific layer/renderer setting that is causing the error you're getting.   If you can send me your mapx file using a 'private message' i can take a look.  

0 Kudos
ThanHtetAung_EsriAu
Esri Regular Contributor

Hi @Wolf ,

I tried and check with my customer for the sample mapx file, but they didn't agree to share.

All in all I managed to figure out the root cause.

I noticed in their mapx files, there are some time stamp value in epoch time format 13 digit numbers, some layer with start time property and 13 digit number in it. In some places, like layer info array, it has 13 digit numbers as well, Currently I manipulated these number and reduced into 10 digit, so that it can be load into mapx document object.

From ArcGIS pro to load these mapx file directly, it is working, no issue at all.

Best Regards,

Than

0 Kudos