Hello,
I'm encountering some serious problems when running MvcMailer in a AsyncController. Here's the code :
public void IndexAsync()
{
AsyncManager.OutstandingOperations.Increment();
Action sendMailHandler = SendChangePasswordEmail;
sendMailHandler.BeginInvoke(ar => SendChangePasswordEmail(), sendMailHandler); Glimps.MVC3 crashes IIS
}
private void SendChangePasswordEmail()
{
var mailer = new PasswordMailer();
var msg = mailer.ForgotPassword();
msg.Send();
AsyncManager.OutstandingOperations.Decrement();
}
It crashes on line var msg = mailer.ForgotPassword(); with the following stack trace :
Informations sur l'exception : System.ArgumentNullException
Pile :
à System.Web.Routing.RouteCollection.GetRouteData(System.Web.HttpContextBase)
à Mvc.Mailer.MailerBase.CreateControllerContext()
à Mvc.Mailer.MailerBase.ViewExists(System.String, System.String)
à Mvc.Mailer.MailerBase.TextViewExists(System.String, System.String)
à Mvc.Mailer.MailerBase.PopulateBody(System.Net.Mail.MailMessage, System.String, System.String, System.Collections.Generic.Dictionary`2<System.String,System.String>)
à Jaskula.CvMedia.UI.Mailers.PasswordMailer.ForgotPassword()
à Jaskula.CvMedia.UI.Areas.Login.Controllers.SendEmailController.SendChangePasswordEmail()
à Jaskula.CvMedia.UI.Areas.Login.Controllers.SendEmailController.b__0(System.IAsyncResult)
à System.Runtime.Remoting.Messaging.AsyncResult.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage)
à System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessageSink)
à System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.DoAsyncCall()
à System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(System.Object)
à System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object)
à System.Threading.ExecutionContext.runTryCode(System.Object)
à System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
à System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
à System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
à System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
à System.Threading.ThreadPoolWorkQueue.Dispatch()
à System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
After providing the CurrentHttpContext i still have a nullReferenceException :
Informations sur l'exception : System.NullReferenceException
Pile :
à Glimpse.Mvc3.Plumbing.GlimpseViewEngine.Process(System.Web.Mvc.ViewEngineResult, Boolean, System.String, System.String, Boolean)
à Glimpse.Mvc3.Plumbing.GlimpseViewEngine.FindView(System.Web.Mvc.ControllerContext, System.String, System.String, Boolean)
à System.Web.Mvc.ViewEngineCollection+<>c__DisplayClassc.b__a(System.Web.Mvc.IViewEngine)
à System.Web.Mvc.ViewEngineCollection.Find(System.Func2<System.Web.Mvc.IViewEngine,System.Web.Mvc.ViewEngineResult>, Boolean) à System.Web.Mvc.ViewEngineCollection.FindView(System.Web.Mvc.ControllerContext, System.String, System.String) à Mvc.Mailer.MailerBase.ViewExists(System.String, System.String) à Mvc.Mailer.MailerBase.TextViewExists(System.String, System.String) à Mvc.Mailer.MailerBase.PopulateBody(System.Net.Mail.MailMessage, System.String, System.String, System.Collections.Generic.Dictionary
2<System.String,System.String>)
à Jaskula.CvMedia.UI.Mailers.PasswordMailer.ForgotPassword()
à Jaskula.CvMedia.UI.Areas.Login.Controllers.SendEmailController.SendChangePasswordEmail()
à Jaskula.CvMedia.UI.Areas.Login.Controllers.SendEmailController.b__0(System.IAsyncResult)
à System.Runtime.Remoting.Messaging.AsyncResult.SyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage)
à System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(System.Runtime.Remoting.Messaging.IMessage, System.Runtime.Remoting.Messaging.IMessageSink)
à System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.DoAsyncCall()
à System.Runtime.Remoting.Proxies.AgileAsyncWorkerItem.ThreadPoolCallBack(System.Object)
à System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object)
à System.Threading.ExecutionContext.runTryCode(System.Object)
à System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode, CleanupCode, System.Object)
à System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
à System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
à System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
à System.Threading.ThreadPoolWorkQueue.Dispatch()
à System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()
Any hints what's going wrong ?
Thanks in advance.