After upgrading to Visual Studio 16.3.0 (Visual Studio for Mac 8.3.1805) Autofac throwns an exeception when doing builder.Build()
in a project that previously worked:
The type 'Autofac.Features.Indexed.KeyedServiceIndex'2' does not implement the interface 'Autofac.Features.Indexed.IIndex'2'
With this release of Visual Studio (and maybe earlier versions too), iOS is compiled using Mono 6.4.0.198 and I suspected that this might be what is introducing the braking change. Alternatively the linker behaves differently with the latest tool-chain. All I can say is that this used to work and now it doesn't.
Following these guidelines is not sufficient: Cross-Platform and Native Applications
To work around the issue, first make sure that Autofac is installed both in the iOS project, Android and the .NET Standard shared project, then choose one of these two options:
Don't link
or Link Framework SDK's Only
--linkskip=Autofac
(case sensitive!) to the Additional mtouch arguments
in iOS Build
found in the iOS project properties. Linker Description file
the compiler will give you usable feedback when you build, if you've made a mistake like misspelling an assembly etc. Also, the Linker Description file
has an identical format across Android and iOS.Note: Option 2 and 3 will only increase your app size a small amount, as it will ensure that all of the Autofac assembly is included in your app package, while all other assemblies not specified as part of 2 or 3 will continue to be linked.
I assume that the needs for one of these work-arounds is an indication that Autofac is currently not linker safe.