Xamarin.Forms Error CS0117

Now that I have completed the first release of Mobile DMX I thought would convert the project over from Xamarin Studio to Visual Studio. I wasn’t able to do this until recently because I have an “Indie Android” licence, which meant I had to use Xamarin Studio, but since MS have bought Xamarin I can now use Visual Studio (Xamarin Studio is deprecated), which is good.

Took a while, though. At first I was getting several hundred errors of the form

error CS0117: 'Resource.Attribute' does not contain a definition for 'mediaRouteSettingsDrawable'

Tracing these back led to lines like

global::NControl.Droid.Resource.Attribute.mediaRouteSettingsDrawable = global::Babbacombe.MobileDmx.Android.Resource.Attribute.mediaRouteSettingsDrawable;

in Resource.designer.cs referring to NControl and XLabs.

Resource.designer.cs is auto-generated at each build, so there was nothing I could do to edit the problems out.

Took some sorting out, but the main problem is that the versions of these libraries in Nuget have been built against earlier versions of Xamarin.Forms.

It looks like the earlier version puts a lot of resource entries in that aren’t in the current version, and this causes problems when the app tries to overwrite the default values put in by the library with values that it hasn’t generated.

The only fix I could find was to fork these libraries myself, build them with the same versions of the libraries and Android target, and use my builds in the app.

The whole mechanism looks very clunky. Apart from wondering why the app has to overwrite values that were filled in in the library when it was built, I wonder why they didn’t use reflection, or a lookup into a dll, rather than generating and compiling this rather large resource file. I suppose it looked like the easiest way to do it at the time.

I do hope they don’t break compatibility like that again, but looking back through the Xamarin forum this seems to be a regular problem.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.