xamarin.ios - Xamarin 更新后 Autofac 在 iOS 上退出解析构造函数

标签 xamarin.ios autofac

所以我今天将我的 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/

相关文章:

ios - MvvmLight 无法为键创建 Controller

c# - 每个请求的 WebApi、Autofac、System.Web.Http.Filters.ActionFilterAttribute 实例

singleton - Autofac SingleInstance无法正常工作

c# - 我自己的带有 NServiceBus 的 Autofac 容器?

xaml - Xamarin Forms Center Collection查看内容

ios - MonoTouch.Dialog 与 UISplitViewController

ios - Xcode 8 Xamarin 构建失败

c# - MonoTouch conformsToProtocol=False 对于有效协议(protocol)

c# - 使用 Autofac 和 Moq 对 HttpResponseMessage 进行单元测试

c# - Dispose 被 Microsoft DependencyInjection 多次调用