Skip to content

Hangfire: Method Not Found for Scheduled Job in EmailService #2504

Open
@Frozzesav

Description

@Frozzesav

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions