在下面的代碼SendAsync失敗的原因是什麼?
public static void Send(SmtpClient smtpClient, MailMessage email)
{
try
{
smtpClient.SendCompleted += (sender, e) =>
{
var x = e.Error; // can't access discarded object
};
smtpClient.SendAsync(email, null);
}
catch // never reach
{
// this works
smtpClient.Send(email);
}
}
你在處理SendCompleted事件嗎?它是否曾被錯誤響應調用過? – 2010-06-21 19:09:15
我剛剛意識到有這個事件,e.Error'說我不能訪問被丟棄的對象......我該如何解決它? – BrunoLM 2010-06-21 19:27:09