Description
I’m using Hangfire to schedule email sending in my .NET application, but I’m encountering an issue where Hangfire cannot find the method for execution.
System.InvalidOperationException: The type Gma.Services.EmailService does not contain a method with signature SendEmailWithStoredBodyAsync(String, Int32, String, Int32, String, String, String, DateTime)
This happens when trying to enqueue a job using:
BackgroundJob.Schedule(() => SendEmailWithStoredBodyAsync( email, emailMessageId, smtpSettings.SmtpServer, smtpSettings.Port, smtpSettings.Username, smtpSettings.Password, smtpSettings.Email, request.SendAt.Value.ToUniversalTime()), TimeSpan.FromMinutes(2));
The method SendEmailWithStoredBodyAsync exists in my EmailService class with the correct signature:
public async Task SendEmailWithStoredBodyAsync( string to, int emailMessageId, string smtpServer, int port, string username, string password, string fromEmail, DateTime sendAt)
Is there a way to ensure Hangfire can recognize and execute the job correctly?