Search code examples
xamarin.iosmvvmcrossxamarin-linker

Xamarin Linker: Default constructor not found for type MvvmCross.Platform.IoC.MvxPropertyInjector


This is the same question as this, but the solution is not working for me. I have a LinkerPleaseInclude.cs file with the following:

public void Include(MvvmCross.Platform.IoC.MvxPropertyInjector injector)
{
    injector = new MvvmCross.Platform.IoC.MvxPropertyInjector();
} 

I'm using Link All as the linker behavior, but I was under the impression that including the above in LinkerPleaseInclude.cs would hint the linker to not strip it out.

Not sure if it matters, but here are some platform details:

Xamarin Studio 6.3

MvvmCross 4.4.0

.NETCore UWP 5.3.3


Solution

  • A file named LinkerPleaseInclude.cs does not preserve anything by itself. It's only a convention used by Mvvmcross.

    So if nothing calls into (or preserve*) your Include method then the linker won't mark it (as required) and the MvxPropertyInjector .ctor won't be marked.

    * adding a [Preserve] attribute on the method will ensure the linker includes it (and everything it calls).