-
-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Coravel Background Service #317
Comments
So I'd uncomment the line with The original exception you were getting If you need more help could you past the constructor method signatures (not the body) for the Thanks! |
Hi James,
Thanks for the prompt response. Here is my constructor etc.
internal class PricingUpdateController : IInvocable
{
public bool testSystem;
public bool calculateStones;
public bool calculateProducts;
public bool calculateMetals;
public bool calculateProductGroupMounts;
public bool calculateOrders;
public bool calculateInvoices;
public bool checkStockAvailable;
public PricingUpdateController(bool TestSystem, bool calculateStones, bool calculateProducts, bool calculateMetals, bool calculateProductGroupMounts, bool calculateOrders, bool calculateInvoices, bool checkStockAvailable)
{
this.testSystem = TestSystem;
this.calculateStones = calculateStones;
this.calculateProducts = calculateProducts;
this.calculateMetals = calculateMetals;
this.calculateProductGroupMounts = calculateProductGroupMounts;
this.calculateOrders = calculateOrders;
this.calculateInvoices = calculateInvoices;
this.checkStockAvailable = checkStockAvailable;
}
public System.Threading.Tasks.Task Invoke()
{
From: James Hickey ***@***.***>
Sent: 04 December 2022 01:13
To: jamesmh/coravel ***@***.***>
Cc: Darren Larner ***@***.***>; Author ***@***.***>
Subject: Re: [jamesmh/coravel] Coravel Background Service (Issue #317)
So I'd uncomment the line with //services.AddTransient<PricingUpdateController>();.
The original exception you were getting Error while validating the service descriptor... means that the constructor of your PricingUpdateController has a mismatch with the parameter you supplied (e.g. the 8 booleans - does your PricingUpdateController class have a constructor with exactly 8 booleans?)
If you need more help could you past the constructor method signatures (not the body) for the PricingUpdateController class?
Thanks!
—
Reply to this email directly, view it on GitHub<#317 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AD36WZL7Z6ZKHUIBMFQCBSLWLPVZ5ANCNFSM6AAAAAASS44JEA>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
For fun, try making the class public instead of internal? Let me know what happens 🤔 |
Yes I did try that and it didn’t work! This is the full exception. Thanks
System.AggregateException
HResult=0x80131500
Message=Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: HMSystemWorkflowService.Controllers.PricingUpdateController Lifetime: Transient ImplementationType: HMSystemWorkflowService.Controllers.PricingUpdateController': Unable to resolve service for type 'System.Boolean' while attempting to activate 'HMSystemWorkflowService.Controllers.PricingUpdateController'.)
Source=Microsoft.Extensions.DependencyInjection
StackTrace:
at Microsoft.Extensions.DependencyInjection.ServiceProvider..ctor(ICollection`1 serviceDescriptors, ServiceProviderOptions options)
at Microsoft.Extensions.DependencyInjection.ServiceCollectionContainerBuilderExtensions.BuildServiceProvider(IServiceCollection services, ServiceProviderOptions options)
at Microsoft.Extensions.DependencyInjection.DefaultServiceProviderFactory.CreateServiceProvider(IServiceCollection containerBuilder)
at Microsoft.Extensions.Hosting.Internal.ServiceFactoryAdapter`1.CreateServiceProvider(Object containerBuilder)
at Microsoft.Extensions.Hosting.HostBuilder.InitializeServiceProvider()
at Microsoft.Extensions.Hosting.HostBuilder.Build()
at Program.<<Main>$>d__0.MoveNext() in C:\Users\darre\source\repos\HMSystem\HMSystemWorkflowService\Program.cs:line 10
This exception was originally thrown at this call stack:
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(System.Type, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain, System.Reflection.ParameterInfo[], bool)
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateConstructorCallSite(Microsoft.Extensions.DependencyInjection.ServiceLookup.ResultCache, System.Type, System.Type, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain)
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.TryCreateExact(Microsoft.Extensions.DependencyInjection.ServiceDescriptor, System.Type, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain, int)
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.GetCallSite(Microsoft.Extensions.DependencyInjection.ServiceDescriptor, Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteChain)
Microsoft.Extensions.DependencyInjection.ServiceProvider.ValidateService(Microsoft.Extensions.DependencyInjection.ServiceDescriptor)
Inner Exception 1:
InvalidOperationException: Error while validating the service descriptor 'ServiceType: HMSystemWorkflowService.Controllers.PricingUpdateController Lifetime: Transient ImplementationType: HMSystemWorkflowService.Controllers.PricingUpdateController': Unable to resolve service for type 'System.Boolean' while attempting to activate 'HMSystemWorkflowService.Controllers.PricingUpdateController'.
Inner Exception 2:
InvalidOperationException: Unable to resolve service for type 'System.Boolean' while attempting to activate 'HMSystemWorkflowService.Controllers.PricingUpdateController'.
From: James Hickey ***@***.***>
Sent: 04 December 2022 01:18
To: jamesmh/coravel ***@***.***>
Cc: Darren Larner ***@***.***>; Author ***@***.***>
Subject: Re: [jamesmh/coravel] Coravel Background Service (Issue #317)
For fun, try making the class public instead of internal? Let me know what happens 🤔
—
Reply to this email directly, view it on GitHub<#317 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AD36WZI7OZYO44JGTRAYXJLWLPWOLANCNFSM6AAAAAASS44JEA>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
So I can confirm your first comments - commenting out the I tried adding some unit tests in the main project against this case - and they pass. Yet, when I create a new real-life .NET project similar to yours, then I am getting the same exception lol. And you are correct that this is not expected behaviour. This happens with other constructor types like integers, strings, etc. And also only when one param is present. I suspect this is something to do with .NET 7 or some new DI stuff that Microsoft changed under the covers (not the first time this happened!) I'll look into this - but for now just don't register the invocable and it seems like it works 🤔 |
No problem, thanks for looking into this. Just to clarify, I am currently running this on .Net 6.
Any ideas on my other issue with the global OnError not working?
From: James Hickey ***@***.***>
Sent: 04 December 2022 02:06
To: jamesmh/coravel ***@***.***>
Cc: Darren Larner ***@***.***>; Author ***@***.***>
Subject: Re: [jamesmh/coravel] Coravel Background Service (Issue #317)
So I can confirm your first comments - commenting out the //services.AddTransient<PricingUpdateController>(); makes this work. Otherwise, something is amiss...
I tried adding some unit tests in the main project against this case - and they pass. Yet, when I create a new real-life .NET project similar to yours, then I am getting the same exception lol.
And you are correct that this is not expected behaviour. This happens with other constructor types like integers, strings, etc. And also only when one param is present.
I suspect this is something to do with .NET 7 or some new DI stuff that Microsoft changed under the covers (not the first time this happened!)
I'll look into this - but for now just don't register the invocable and it seems like it works 🤔
—
Reply to this email directly, view it on GitHub<#317 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AD36WZLBZUVC7UYYWGAOWKTWLP4ADANCNFSM6AAAAAASS44JEA>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
For |
It’s just being ignored for some reason. Here is a screenshot:
***@***.***
From: James Hickey ***@***.***>
Sent: 04 December 2022 02:24
To: jamesmh/coravel ***@***.***>
Cc: Darren Larner ***@***.***>; Author ***@***.***>
Subject: Re: [jamesmh/coravel] Coravel Background Service (Issue #317)
For OnError -> try throwing an exception from inside your invocable's Invoke method. It should trigger.
—
Reply to this email directly, view it on GitHub<#317 (comment)>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AD36WZIT75PQXSAO7NPQ52TWLP6E7ANCNFSM6AAAAAASS44JEA>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
What happens if you update your controller like public record PricingUpdateControllerConfiguration(
bool TestSystem;
bool CalculateStones;
bool CalculateProducts;
bool CalculateMetals;
bool CalculateProductGroupMounts;
bool CalculateOrders;
bool CalculateInvoices;
bool CheckStockAvailable);
public class PricingUpdateController : IInvocable
{
private readonly PricingUpdateControllerConfiguration _configuration;
public PricingUpdateController(PricingUpdateControllerConfiguration configuration)
{
_configuration = cofiguration;
}
// ...
} and call it with host.Services.UseScheduler(scheduler =>
{
scheduler.ScheduleWithParams<PricingUpdateController>(
new PricingUpdateControllerConfiguration(false, false, false, true, true, true, false, false)
).EveryThirtySeconds().PreventOverlapping(nameof(PricingUpdateController));
}) |
Hi, I have implemented Coravel quite successfully and is working great. I have a couple of issues which is probably something I'm not doing right. My code is below. The queries are:
Message=Some services are not able to be constructed (Error while validating the service descriptor 'ServiceType: PricingUpdateController Lifetime: Transient ImplementationType: PricingUpdateController': Unable to resolve service for type 'System.Boolean' while attempting to activate 'PricingUpdateController'.)
Any help or guidance would be appreciated. Thanks and here is my relevant code:
The text was updated successfully, but these errors were encountered: