所以我今天将我的 Xamarin 安装更新到最新的稳定版本。自更新以来,我的应用程序无法在 iOS 上运行(在 Android 上运行良好)......错误是它无法解析构造函数。
Autofac.Core.DependencyResolutionException: No constructors on type 'FutureState.AppCore.Migrations.Migration001' can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'.
我原来的构造函数是
public Migration001(IUserRepository userRepository,
IRoleRepository roleRepository,
IPermissionRepository permissionRepository,
IPasswordHasher passwordHasher)
{
_userRepository = userRepository;
_roleRepository = roleRepository;
_permissionRepository = permissionRepository;
_passwordHasher = passwordHasher;
MigrationVersion = 1;
}
但我什至尝试将其更改为服务位置,只是为了查看 Autofac 是否会找到构造函数。
public Migration001()
{
_userRepository = App.Container.Resolve<IUserRepository>();
_roleRepository = App.Container.Resolve<IRoleRepository>();
_permissionRepository = App.Container.Resolve<IPermissionRepository>();
_passwordHasher = App.Container.Resolve<IPasswordHasher>();
MigrationVersion = 1;
}
但不幸的是,它导致了完全相同的问题。
Autofac.Core.DependencyResolutionException: No constructors on type 'FutureState.AppCore.Migrations.Migration001' can be found with the constructor finder 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder'.
什么会导致这样的事情?这是一个 Xamarin.Forms 应用程序,因此在 Android 上运行完全相同的代码没有问题。
最佳答案
看起来这是当时 Xamarian 版本的一个问题。我已经重新更新到最新版本(昨天)并且不再有这个问题。
此外,在 2014 年 9 月的版本中还有许多重大错误,因此如果您使用的是 3.5...升级。
关于xamarin.ios - Xamarin 更新后 Autofac 在 iOS 上退出解析构造函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25671480/