I have a very weird issue occurring only in production environment. The exception has the message
"Delegate to an instance method cannot have null 'this'".
The method where the exception is being thrown is very simple, and worked for a long time, so the problem must be an obscure dependency in the environment, or something like that...
I'm using ASP.NET Web API, hosted in Azure, and the action method of controller is executed via AJAX.
Here is the code where the exception was thrown:
public class BlacklistService : IBlacklistService
{
public bool Verify(string blacklist, string message)
{
if (string.IsNullOrEmpty(blacklist)) return true;
var split = blacklist.ToLower().Split(';'); // exception is thrown here
return !split.Any(message.Contains);
}
}
Here is the relevant part of stack trace:
at System.MulticastDelegate.ThrowNullThisInDelegateToInstance()
at System.MulticastDelegate.CtorClosed(Object target, IntPtr methodPtr)
at MyApp.Business.Services.BlacklistService.Verify(String blacklist, String message)
at MyApp.Business.Services.ContactMessageFactory.GetVerifiedStatus(String mensagem)
at MyApp.Business.Services.ContactMessageFactory.GetMailMessage(ContactForm contactForm)
at MyApp.Business.ContactEmailService.Send(ContactForm contactForm)
Someone can figure out the possible causes of this exception? Thanks in advance.