小编Leo*_*lva的帖子

仅在生产环境中抛出 MulticastDelegate 异常

我有一个仅在生产环境中发生的非常奇怪的问题。异常有消息

“委托给实例方法不能有 null 'this'”。

抛出异常的方法非常简单,并且工作了很长时间,所以问题一定是环境中的模糊依赖,或者类似的东西......

我正在使用托管在 Azure 中的 ASP.NET Web API,控制器的操作方法是通过 AJAX 执行的。

这是抛出异常的代码:

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);
    }
}
Run Code Online (Sandbox Code Playgroud)

这是堆栈跟踪的相关部分:

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)
Run Code Online (Sandbox Code Playgroud)

有人可以找出导致此异常的可能原因吗?提前致谢。

c# asp.net-mvc split azure multicastdelegate

5
推荐指数
1
解决办法
569
查看次数

标签 统计

asp.net-mvc ×1

azure ×1

c# ×1

multicastdelegate ×1

split ×1