我僅在生產環境中發生了一個非常奇怪的問題。 有個例外僅在生產環境中拋出MulticastDelegate異常
「委託給一個實例方法不能有'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);
}
}
這裏是堆棧跟蹤的相關部分:
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)
有人能弄清楚這個異常的可能原因是什麼?提前致謝。
請您分享您調用驗證方法的委託部分的代碼嗎? –