Activation error occured while trying to get instance of type IAuthServices, key ""
在用Microsoft.Practices.ServiceLocation.Current.GetInstance<IAuthServices>()获取一个对象的实例的时候报错,说是key没有找到。应该就是没有注册,后来调试果然是。
在初始化的地方Bootstrapper加上注册就可以了
protected override void ConfigureAggregateCatalog() { this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(Bootstrapper).Assembly)); this.AggregateCatalog.Catalogs.Add(new AssemblyCatalog(typeof(Frame.Security.Service.AuthServices).Assembly)); }
如果我的文章对你有帮助,就点一下推荐吧.(*^__^*)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步