我正在使用 Postal 库在 ASP.NET MVC5 Web 项目中发送电子邮件。从控制器调用时它工作正常。但是,我计划了一些工作来使用 fluentScheduler 发送电子邮件。我正在调用一种使用http://aboutcode.net/postal/outside-aspnet.html此处的说明发送电子邮件的方法。
但是每次运行后台任务时,我仍然会遇到相同的异常。
object reference not set to an instance of an object
这是堆栈:
at Glimpse.AspNet.AspNetFrameworkProvider.get_HttpRequestStore()
at Glimpse.Core.Framework.Factory.<>c__DisplayClass5.<InstantiateRuntimePolicyStrategy>b__4()
at Glimpse.Core.Extensions.AlternateMethodContextExtensions.TryProceedWithTimer(IAlternateMethodContext context, TimerResult& timerResult)
at Glimpse.Core.Extensibility.AlternateMethod.NewImplementation(IAlternateMethodContext context)
at Glimpse.Core.Extensibility.AlternateTypeToCastleInterceptorAdapter.Intercept(IInvocation invocation)
at Castle.DynamicProxy.AbstractInvocation.Proceed()
at Castle.Proxies.IViewEngineProxy.FindView(ControllerContext controllerContext, String viewName, String masterName, Boolean useCache)
at System.Web.Mvc.ViewEngineCollection.<>c__DisplayClass6.<FindView>b__4(IViewEngine e)
at System.Web.Mvc.ViewEngineCollection.Find(Func`2 lookup, Boolean trackSearchedPaths)
at System.Web.Mvc.ViewEngineCollection.Find(Func`2 cacheLocator, Func`2 locator)
at System.Web.Mvc.ViewEngineCollection.FindView(ControllerContext controllerContext, String viewName, String masterName)
at Postal.EmailViewRenderer.CreateView(String viewName, ControllerContext controllerContext)
at Postal.EmailViewRenderer.Render(Email email, String viewName)
at Postal.EmailService.CreateMailMessage(Email email)
at Postal.EmailService.Send(Email email)
at Postal.Email.Send()
at CallSite.Target(Closure , CallSite , Object )
at System.Dynamic.UpdateDelegates.UpdateAndExecuteVoid1[T0](CallSite site, T0 arg0)
at Bay3.Helpers.EmailHelper.FollowerEmail(String to, String link, String articleName, String lang) in e:\_TFS2\Bay3\Bay3\Helpers\EmailHelper.cs:line 39
我希望以前有人遇到过同样的问题