Xamarin.Forms Messaging center failing silently

I had a problem with Xamarin.Forms MessagingCenter – as sometimes the messages disappeared. Code that on most occasions worked nicely failed silently and from debug output – the messages never reached the subscription methods. What I eventually found out was happening (after days of frustration) was that one of the subscriptions was updating the UI and since this is on a thread other than the main one – it just failed silently and the next message subscription never got the message. This is not a 100% diagnostic (I don’t care to waste more time on this) but moving the UI updates explicitly to the main thread solved the issue. Hope this helps someone … a day or two of pointless debugging 🙂

Weekly Wednesday Tech Talk – Theme1: Xamarin.Forms

Theme for the first meeting (april 8th): Xamarin.Forms

Our software lunch chat will start with a Xamarin discussion – possibly (and very likely) touching on issues like comparison with Flutter and React Native – but leaving the big discussion about that for later.  The focus of the meeting is developers in Iceland – we will choose the language based on attendance, but no Danish please 🙂

This is a technical meeting – so we’ll expect diving into code and sharing screens where applicable.

Zoom link: https://zoom.us/meeting/918675917

FontAwesome .otf not working in Xamarin IOS

Had a problem of icons always displaying properly in preview but only showing up as boxes in the IOS emulators.   Went through all the usual manuals but the following 2 things were not often mentioned.

  1. Make sure to include “Fonts provided by application” key in Info.plist with the array of full font FILE NAMES included in the resource folder, e.g. “FontAwesome5Solid.otf
  2. Set the build action of the .otf files to Content and “Always copy”

MT2001 could not link assemblies – Xamarin IOs

Had this build error – preventing all IOS development. Searched around for fixes all over the place but of course the solution was simple as usual 🙂    I had accidentally added a direct Mono.dll dependency in my base project and was referencing the Android namespace (using Android.***) in a couple of (XML and c#) files. This caused the MT2001 horror 🙂  Again, learned a lot about the build procedure during the debugging process but the solution was just toooo simple as usual. Hope this helps someone.

Facebook OWIN login not working – returning null from AuthenticationManager.AuthenticateAsync

Using OWIN 4.0.1 on my sites – the google authentication worked fine but I couldn’t find out why the Facebook process always returned null – redirecting only to the same URL – adding the typical #_=_ to the /Account url.    Finally thought of my Cloudeflare proxy and that it might be impacting Facebook’s response.  Turning off the cache solved the issue – but maaaaan how much I have learned in the past 10+ hours spent on this 😉  #liveandlearn

Xamarin.Forms: Error parsing XML: not well-formed (invalid token) when compiling Android

Suddenly my Android Xamarin.Forms project stopped compiling because of a couple of corrupt XML files. The error message is: “Error parsing XML: not well-formed (invalid token)”

Turns out that at that the source resource files in the

C:\Users\Geir\AppData\Local\Xamarin\Xamarin.Android.Support.v7.AppCompat\23.3.0.0\embedded\res\

folder had been corrupted, probably by my antivirus program, there was a path to Avira among the unreadable (I have no clue what kind of encoding or content was in the file – it was not XML)

This file is on compile time copied into the  \obj\Debug\resourcecache\[some-identifier]\res\ folder where it is of course unparsable as XML.

Hope this helps someone, took me a while to figure out from where the xml file was copied (of course file search should have come to my mind an hour earlier than it did 🙂 )

Capture

Visual Studio 2017 – .net 4.5.2 – The compiler failed with error code 255.

This gave me the reason to start blogging again – just with the hope that a single developer might get some extra moments doing fun coding instead of analysing this horrible error …. it took me some useless IIS and permission experimenting before stumbling upon this solutijon.

http://stackoverflow.com/questions/32282880/publish-website-without-roslyn

“When you create a new web project, two nuget packages automatically added to your project. If you remove them, your problem should be solved. Package names are: “Microsoft.CodeDom.Providers.DotNetCompilerPlatform” and “Microsoft.Net.Compilers”.

JQuery ajax ($.ajax()) returning to error function despite success (200 ok) response

Turns out that returning void from (asp.net mvc) server function, but jquery ajax call data type was set to json – so when receiving no data back – the ajax function returns to the error function.

So the example below would always alert “error” as the server controller action return was void

$.ajax({type: “POST”,url: “/MyController/MyAction/”,data: [postData], success: function (data) { alert(“success”); }, error: function () { alert(“error”); } });