crossvertise / ActionMailerNext

Fork of ActionMailer.Net, A easy to use library to generate emails with razor views
MIT License
42 stars 24 forks source link

Standalone: RazorEngine.Templating.TemplateCompilationException #8

Open tylerjharden opened 10 years ago

tylerjharden commented 10 years ago

I have this issue with the Standalone version of ActionMailerNext. After fooling around for 2 hours and finally figuring out how to properly point my views path, I now receive this exception when the template is compiling.

The standalone sample app also has zero "sample" code, so no idea where to start with this. Saw several posts online with this exact exception in different libraries where people were using RazorEnginer directly to parse e-mail templates. More details:

Server Error in '/' Application.

Unable to compile template. The name 'WriteAttribute' does not exist in the current context

Other compilation errors may have occurred. Check the Errors property for more information.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: RazorEngine.Templating.TemplateCompilationException: Unable to compile template. The name 'WriteAttribute' does not exist in the current context

Other compilation errors may have occurred. Check the Errors property for more information.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[TemplateCompilationException: Unable to compile template. The name 'WriteAttribute' does not exist in the current context

Other compilation errors may have occurred. Check the Errors property for more information.] RazorEngine.Compilation.DirectCompilerServiceBase.CompileType(TypeContext context) +525 RazorEngine.Templating.TemplateService.CreateTemplateType(String razorTemplate, Type modelType) +1413 RazorEngine.Templating.TemplateService.GetTemplate(String razorTemplate, Object model, String cacheName) +748 RazorEngine.Templating.TemplateService.GetTemplate(String razorTemplate, Object model, String cacheName) +80 RazorEngine.Templating.TemplateService.Resolve(String cacheName, Object model) +630 ActionMailerNext.Standalone.RazorEmailResult.Compile(T model, Boolean trimBody) +1341 ActionMailerNext.Standalone.RazorMailerBase.Email(String viewName, T model, Boolean trimBody) +675 Squid.Mail.MailController.ConfirmEmail(WishLuUser model) +569 Squid.User.WishLuUser.SendEmailVerification() +389 Disco.Controllers.AdminController.email() +84 lambda_method(Closure , ControllerBase , Object[] ) +79 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +242 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +39 System.Web.Mvc.Async.AsyncControllerActionInvoker.b39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +12 System.Web.Mvc.Async.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult) +139 System.Web.Mvc.Async.AsyncInvocationWithFilters.b3d() +112 System.Web.Mvc.Async.<>cDisplayClass46.b3f() +452 System.Web.Mvc.Async.<>cDisplayClass33.b32(IAsyncResult asyncResult) +15 System.Web.Mvc.Async.<>cDisplayClass2b.b1c() +37 System.Web.Mvc.Async.<>cDisplayClass21.b1e(IAsyncResult asyncResult) +241 System.Web.Mvc.Controller.b1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +111 System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53 System.Web.Mvc.Async.WrappedAsyncVoid1.CallEndDelegate(IAsyncResult asyncResult) +19 System.Web.Mvc.MvcHandler.b5(IAsyncResult asyncResult, ProcessRequestState innerState) +51 System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +111 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +606 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +288

tylerjharden commented 10 years ago

Note: I have implemented my mail controller and views in a base class library that is being called from an ASP.NET website. Both projects have the proper references and things are setup properly in config as far as I know. One thing I think contributes to this issue is the inability to "add" a proper RazorEnginer view file to a class library since it is not an MVC Razor project.

ozzyknox commented 9 years ago

I am experiencing the same issue as described by tylerjharden. Is there any resolution for this?