Hi,
I am facing an issue with scheduled job, that its not able to start automatically. I am getting below error:
UnableToStart | Exception has been thrown by the target of an invocation. [Activation error occurred while trying to get instance of type ILogisticProductsService, key ""] |
I have a sercvice injected into scheduled job constructor. The job works fine if I manually trigger the job.
code snipest:
public class AgrodeskSendLogisticProductsJob : ScheduledJobBase
{
private readonly ILogisticProductsService _logisticProductsService;
public AgrodeskSendLogisticProductsJob()
{
_logisticProductsService = ServiceLocator.Current.GetInstance<ILogisticProductsService>();
}
public AgrodeskSendLogisticProductsJob(ILogisticProductsService logisticProductsService)
{
_logisticProductsService = logisticProductsService;
}
private static IUserImpersonation UserImpersonation
{
get { return ServiceLocator.Current.GetInstance<IUserImpersonation>(); }
}
public override string Execute()
{
PrincipalInfo.CurrentPrincipal = UserImpersonation.CreatePrincipal("saam.farmer@lm2.com");
_logisticProductsService.SendProducts();
return "OK";
}
}
The dependancies are resolved in dependancy resolver.
container.For<ILogisticProductsService>().Use<LogisticProductsService>();
anyone could you help whats wrong with this approach?