I have a Xamarin Forms project using .NET Standard 2.0 utilizing Autofac for DI.
The project is for Android, iOS and UWP.
When I run the project with iOS or UWP everything works as expected.
When running it in Android i get a "No accessible constructors were found ..." exception when trying to resolve MainViewModel
.
Registration: builder.RegisterType<MainViewModel>().AsSelf();
Resolving MainViewModel:
public MainViewModel MainPage
{
get
{
using (var scope = _container.BeginLifetimeScope())
{
return _container.Resolve<MainViewModel>();
}
}
}
MainViewModel constructor:
public MainViewModel(
ISecureDatabaseService secureDb,
IReceiptQueuedSenderHandler receiptQueuedSenderHandler)
Both ISecureDatabaseService
and IReceiptQueuedSenderHandler
is registered with Autofac prior to registering MainViewModel
.
Any idea what is going on here and why things work smoothly with iOS and UWP and breaks on Android?
Could it be related to Linking in Xamarin Forms?
I'm using Autofac 4.8. I've tried with Autofac 4.6.2 too, but with same results.