legendinfo returned from layer.GetLegendInfosAsync() appears to be blank in UWP release build

1733
8
Jump to solution
08-03-2021 03:04 PM
PaulFarrow
New Contributor II

I have legendinfos returned from layer.GetLegendInfosAsync() and works fine in iOS (release and debug builds) and UWP (debug build) but not UWP in a release build.

Any one else experiencing this issue?  We are using 100.10 runtime for Xamarin Forms.

Thanks

Farrow

0 Kudos
1 Solution

Accepted Solutions
MichaelBranscomb
Esri Frequent Contributor

@johnselkirkssp @PaulFarrow 

Can you try this?

 

// Work around for .NET native compilation issue where ArcGIS Runtime assemblies 
// get optimized away: Explicitly define the assemblies that are used. 
List<Assembly> assembliesToInclude = new List<Assembly>();
assembliesToInclude.Add(typeof(Esri.ArcGISRuntime.UI.Controls.MapView).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(Esri.ArcGISRuntime.Toolkit.Xamarin.Forms.SymbolDisplay).GetTypeInfo().Assembly);
Xamarin.Forms.Forms.Init(e, assembliesToInclude);

 

---

8/11/2021 Edited the code to remove the reference to Map, leaving just the references that contain customer renderers.

View solution in original post

0 Kudos
8 Replies
johnselkirkssp
New Contributor

To expand on what @PaulFarrow is saying. We utilize the Toolkit SymbolDisplay like this:

<forms:SymbolDisplay Symbol="{Binding Symbol}" />

This works perfectly in iOS, Android in debug and full builds.

UWP also works when running in debug but when we do a real Release UWP build, the symbols never display. The layer.GetLegendInfosAsync() call definitely returns symbols and we even put code in to replace null symbols with a SimpleMarkerSymbol if that property is null (there were not any but we are to that point). 

@MikeBranscomb @dotMorten - could really use your help on this one if you have any ideas.

John.

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

John, Paul,

If you run the UWP Toolkit Samples in Release mode do the LayerLegend/Legend samples display legend images?

Thanks  

0 Kudos
PaulFarrow
New Contributor II

John wanted me to post the screen shots from the legend sample.  Here you can see in pure release mode which doesn't load the mapview - we had this issue also and overcame that by telling the xamarin forms init method about the mapview types.   I made the same change to the latest toolkit code and now you can see the map load but no symbols in the legend.  I did try to load the symbol types the same way but to no avail.

Screenshots attached - names explain what they are.

0 Kudos
johnselkirkssp
New Contributor

Hi @MichaelBranscomb,

Thanks for responding.

The samples also fail between Debug and Release (video attached).

The only thing I did to the code currently in main was to change the <UseNugetPackage>100.11.0</UseNugetPackage> in the Directory.Build.props.

I've attached a (badly edited!) video to show both Release and then Debug builds of the samples running.

John.

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

@johnselkirkssp @PaulFarrow 

Can you try this?

 

// Work around for .NET native compilation issue where ArcGIS Runtime assemblies 
// get optimized away: Explicitly define the assemblies that are used. 
List<Assembly> assembliesToInclude = new List<Assembly>();
assembliesToInclude.Add(typeof(Esri.ArcGISRuntime.UI.Controls.MapView).GetTypeInfo().Assembly);
assembliesToInclude.Add(typeof(Esri.ArcGISRuntime.Toolkit.Xamarin.Forms.SymbolDisplay).GetTypeInfo().Assembly);
Xamarin.Forms.Forms.Init(e, assembliesToInclude);

 

---

8/11/2021 Edited the code to remove the reference to Map, leaving just the references that contain customer renderers.

0 Kudos
PaulFarrow
New Contributor II
Looks like adding the Xamarin.forms.symboldisplay did it.
Thanks
Cheers
Paul
0 Kudos
johnselkirkssp
New Contributor

Many thanks @MichaelBranscomb - we owe you a beer or 3!!

0 Kudos
MichaelBranscomb
Esri Frequent Contributor

Not at all, glad you raised this - there's not a lot of doc on it, so it's good to establish a consistent pattern in all our public sample code.

It turns out we've had the workaround in our regular samples viewer for some time but hadn't applied it to the toolkit samples. We've done that now too.

https://github.com/Esri/arcgis-runtime-samples-dotnet/blob/74397e25e1fb5bad16cb4a8ffca6fa066c9b3292/...

https://github.com/Esri/arcgis-toolkit-dotnet/blob/7ee28956aed504aeabc842ea697cca6e2bbec283/src/Samp...

 

Recently also found this blog post: https://tomsoderling.github.io/what-every-Xamarin.Froms-developer-needs-to-know-about-UWP/ 

0 Kudos