我在本地执行 Task.Run完全没有问题,但是当我部署到服务器上时,发现没有效果,于是我用log记录操作日志,但是只能记录到图片里面的LogInfo,对于 _eventBus.RaiseEvent(reviewEvent)却没反应,并且也没有捕获到异常,是什么原因?
已经知道大概原因了,因为在开始已经使用了 _eventBus.Publish(command),里面异步调用了 _eventBus.RaiseEvent(reviewEvent),可能是_eventBus.Publish先结束,释放了eventBus。但是两个是在不同的类里面,并且不同的构造函数注入的。
_eventBus.RaiseEvent(reviewEvent)
这个方法里是否有日志?可以看看执行效果
我刚加了日志从新执行了下,奇怪,我本地都没有错误,我看看什么原因
Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.
System.ObjectDisposedException: Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.
at Autofac.Core.Lifetime.LifetimeScope.ResolveComponent(IComponentRegistration registration, IEnumerable1 parameters) at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable
1 parameters, Object& instance)
at Autofac.ResolutionExtensions.ResolveOptionalService(IComponentContext context, Service service, IEnumerable1 parameters) at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType, IEnumerable
1 parameters)
at Autofac.ResolutionExtensions.ResolveOptional(IComponentContext context, Type serviceType)
at Autofac.Extensions.DependencyInjection.AutofacServiceProvider.GetService(Type serviceType)
at Blog.Domain.Core.Bus.EventBus.RaiseEvent[TEventData](TEventData eventData)