1. 使用场景,在内部创建一个接口,由于这个接口不对外提供任何的服务,只是内部逻辑使用,故不继承IApplicationService 接口和实现ApplicationService

1.1 接口实现类只是简单实现了接口方法,并没有继承 ApplicationService

2. 使用的时候是通过构造函数进行注入使用,例如

2.1 运行起来就直接报错了

Host terminated unexpectedly!
Volo.Abp.AbpInitializationException: An error occurred during the initialize Volo.Abp.Modularity.OnApplicationInitializationModuleLifecycleContributor phase of the module Volo.Abp.BackgroundWorkers.Quartz.AbpBackgroundWorkersQuartzModule, Volo.Abp.BackgroundWorkers.Quartz, Version=5.2.2.0, Culture=neutral, PublicKeyToken=null: An exception was thrown while activating λ:Volo.Abp.BackgroundWorkers.Quartz.IQuartzBackgroundWorker[] -> ZZJCApiOrDeviceModule.Domain.Worker.PlcWorker.. See the inner exception for details.---> Autofac.Core.DependencyResolutionException: An exception was thrown while activating λ:Volo.Abp.BackgroundWorkers.Quartz.IQuartzBackgroundWorker[] -> ZZJCApiOrDeviceModule.Domain.Worker.PlcWorker.---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'ZZJCApiOrDeviceModule.Domain.Worker.PlcWorker' can be invoked with the available services and parameters:
Cannot resolve parameter 'ZZJCApiOrDeviceModule.Application.PlcServices.plcAppService plcAppService' of constructor 'Void .ctor(Volo.Abp.EventBus.Local.ILocalEventBus, ZZJCApiOrDeviceModule.Application.PlcServices.plcAppService)'.at Autofac.Core.Activators.Reflection.ReflectionActivator.GetAllBindings(ConstructorBinder[] availableConstructors, IComponentContext context, IEnumerable`1 parameters)at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters)at Autofac.Core.Activators.Reflection.ReflectionActivator.<ConfigurePipeline>b__11_0(ResolveRequestContext ctxt, Action`1 next)at Autofac.Core.Resolving.Middleware.DisposalTrackingMiddleware.Execute(ResolveRequestContext context, Action`1 next)   at Autofac.Builder.RegistrationBuilder`3.<>c__DisplayClass41_0.<PropertiesAutowired>b__0(ResolveRequestContext ctxt, Action`1 next)at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)--- End of inner exception stack trace ---at Autofac.Core.Resolving.Middleware.ActivatorErrorHandlingMiddleware.Execute(ResolveRequestContext context, Action`1 next)at Autofac.Core.Resolving.Middleware.SharingMiddleware.Execute(ResolveRequestContext context, Action`1 next)at Autofac.Core.Resolving.Middleware.CircularDependencyDetectorMiddleware.Execute(ResolveRequestContext context, Action`1 next)at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, ResolveRequest request)at Autofac.Core.Resolving.ResolveOperation.ExecuteOperation(ResolveRequest request)at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable`1 parameters, Object& instance)at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters)at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)at Volo.Abp.BackgroundWorkers.Quartz.AbpBackgroundWorkersQuartzModule.OnApplicationInitializationAsync(ApplicationInitializationContext context)at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task)at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---at Nito.AsyncEx.Synchronous.TaskExtensions.WaitAndUnwrapException(Task task)at Nito.AsyncEx.AsyncContext.Run(Func`1 action)at Volo.Abp.Modularity.ModuleManager.InitializeModules(ApplicationInitializationContext context)--- End of inner exception stack trace ---at Volo.Abp.Modularity.ModuleManager.InitializeModules(ApplicationInitializationContext context)at Volo.Abp.AbpApplicationBase.InitializeModules()at Microsoft.AspNetCore.Builder.AbpApplicationBuilderExtensions.InitializeApplication(IApplicationBuilder app)at WMS.Startup.Configure(IApplicationBuilder app, IWebHostEnvironment env, at System.RuntimeMethodHandle.InvokeMethod(Object target, Span`1& arguments, Signature sig, Boolean constructor, Boolean wrapExceptions)at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)at Microsoft.AspNetCore.Hosting.ConfigureBuilder.Invoke(Object instance, IApplicationBuilder builder)at Microsoft.AspNetCore.Hosting.GenericWebHostService.StartAsync(CancellationToken cancellationToken)at Microsoft.Extensions.Hosting.Internal.Host.StartAsync(CancellationToken cancellationToken)at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)at Microsoft.Extensions.Hosting.HostingAbstractionsHostExtensions.RunAsync(IHost host, CancellationToken token)

2.3 解决方法,可能是没有继承ApplicationService,它无法进行初始化,导致注入的时候,构造函数无法正常解析。所以直接在接口实现类加入一个 生命周期函数 ITransientDependency 来进行初始化,就正常了

Abp 构造注入服务接口后运行报错 Host terminated unexpectedly!相关推荐

  1. Maven打包后运行报错

    Maven打包后运行报错 场景描述 今天在用Maven打包的时候发现打完后的jar包无法正常执行,一开始我以为是依赖问题.结果在摸索中发现有一个技巧可以解决问题. 解决方法 1.先clean 2.然后 ...

  2. python-barcode 使用pyinstaller打包后运行报错cannot open resource

    python-barcode 使用pyinstaller打包后运行报错cannot open resource 问题描述: 使用pycharm可以正常生成条码,但是使用pyinstaller打包后,提 ...

  3. python使用pyinstaller打包后运行报错排查思路

    程序使用win10 ,python39 编写 使用pyinstaller打包成exe 在本机运行正常在其他win7电脑运行报错 报错原因: python3.9 不支持win7系统 解决方案:使用pyt ...

  4. electron安装后运行报错解决方法

    electron安装方法: npm install electron 或 yarn add electron 但由于electron文件较大,安装运行报错说明下载不完整! 好多次下载基本都无法运行,下 ...

  5. webpack安装 webpack-dev-server后运行报错

    webpack安装 webpack-dev-server后进行实时监听报错 webpack安装插件 webpack-dev-server后进行实时监听,重新运行npm run dev报错 一.问题现象 ...

  6. Youtube 预装到系统后运行报错

    问题: so已经编译到/system/lib 里,但是运行Youtube 还是报找不到对应的so文件. 环境: Android 6.0,Youtube 2.07.02 报错打印如下: 01-20 14 ...

  7. 使用craco start后运行报错

    用craco start遇到了这个错误,报错如下: This error probably occurred because you updated react-scripts or craco. P ...

  8. 解压修改jar包后运行报错:Unable to open nested entry ‘BOOT-INF/lib/**.jar‘. It has been compressed

    背景 打部署jar包后,使用winwar解压工具,修改了里面的配置文件,和lib里面的一个引用包的配置文件,报这个错: Unable to open nested entry 'BOOT-INF/li ...

  9. idea生成单元测试后运行报错:java.net.ConnectException: Connection refused:

    从官网下载了一个最新的idea(2017.1.4 community),多一个一个类写了一个单元测试,测试代码都没写,然后运行测试,竟然报错,报错为Error connecting to 127.0. ...

最新文章

  1. mysql索引与约束有什么关系_MySQL 约束与索引
  2. 点游出行提供内地与香港游客高质量的旅程
  3. LeetCode-1052:爱生气的书店老板
  4. Redmi K50全系售价曝光:电竞版颠覆骁龙8旗舰定价
  5. 《黑马程序员》 block的使用(Objective - c语法)
  6. 程序中,序列化与反序列化
  7. lex yacc 入门教程(3)正则表达式和lex变量及函数
  8. 冒泡排序、选择排序、二分查找排序
  9. linux下安装anconda
  10. Why hash maps in Java 8 use binary tree instead of linked list?
  11. CodeBlocks下载与安装
  12. 浅谈Marlin2.0
  13. 360cdn能挡住cc攻击_云防CDN是网页CC攻击的克星?cdn集群防御
  14. 聊聊CVE漏洞编号和正式公开那些事
  15. snipeit 安装、备份文件恢复
  16. ASEMI代理AD823AARZ-RL原装ADI车规级AD823AARZ-RL
  17. [文献阅读]—Google’s Multilingual Neural Machine Translation System: Enabling Zero-Shot Translation
  18. Windows Phone 7体验
  19. vjudge总是显示上一次的结果,比如wrong answer,因为代码和上次雷同(为什么自己测试没问题,总是wrong answer,vjudge提交失败,vjudge提交限制,时间限制,次数限制)
  20. windows10任务栏透明

热门文章

  1. Java SE 005 运算符 续
  2. 一台主机连接两台显示器单独分开工作
  3. 2021网易游戏雷火2021春招游戏功能测试工程师 笔试记录----春招补录
  4. 软件评测师题库--程序语言基础知识
  5. Cohen's kappa coefficient
  6. HCIE(M-LAG)
  7. elementUI表格自动刷新
  8. windows重装系统
  9. 2022.05.20-电脑切换全屏与非全屏(特别是谷歌浏览器)的时候会发生卡顿黑屏
  10. 使用ZED Mini 相机运行ORB-SLAM2