smsohan / MvcMailer

A Mailer for ASP.Net MVC that forms the Email Body using MVC Views (Razor etc.) following Ruby on Rails ActionMailer style
MIT License
582 stars 178 forks source link

Value does not fall within the expected range #117

Open cgralph opened 10 years ago

cgralph commented 10 years ago

Hello,

In the website that i am working on, i need to generate a PDF file asynchronously and then notify the user that the file is available thru email.

But I get this error when calling PopulateBody in all overloads:

System.ArgumentException: {"Value does not fall within the expected range."} at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode) at System.Web.Hosting.IIS7WorkerRequest.GetServerVariableInternal(String name) at System.Web.Hosting.IIS7WorkerRequest.GetServerVariable(String name) at System.Web.Hosting.IIS7WorkerRequest.GetRemoteAddress() at System.Web.HttpWorkerRequest.IsLocal() at System.Web.HttpRequestWrapper.get_IsLocal() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.Mvc.WebViewPage.ExecutePageHierarchy() at System.Web.WebPages.StartPage.RunPage() .......

I saw this issue: https://github.com/smsohan/MvcMailer/issues/60. but i believe this is a different case. I tried to send an email before an ActionResult is returned and it worked with no error. It works well if an MVC Action is not yet dismissed (in my opinion).

toddca commented 10 years ago

I see this same error and I am using InTransientScope() on the emailer class via Ninject.