Question

I use RazorEngine V 3.0.8 in my project(Asp.net MVC 4) for parsing email template. I use system.web.dll version 1.0.0 in my project. Every thing is ok on my pc as local site and It works. but on server this error was shown:

Could not load file or assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

but I didn't use 'System.Web.Razor, Version=2.0.0.0 on my project. also when I add 'System.Web.Razor, Version=2.0.0.0 to my project , I have problem for parsing email template with RazorEngine and this error was shown:

System.IO.FileLoadException: Could not load file or assembly 'System.Web.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) File name: 'System.Web.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' at RazorEngine.Compilation.DefaultCompilerServiceFactory.CreateCompilerService(Language language) at RazorEngine.Templating.TemplateService.CreateTemplateType(String razorTemplate, Type modelType) at RazorEngine.Templating.TemplateService.CreateTemplate[T](String razorTemplate, T model) at RazorEngine.Templating.TemplateService.Parse[T](String razorTemplate, T model) at RazorEngine.Razor.Parse[T](String razorTemplate, T model) at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) at Service.Implementation.EmailService.InitializeTemplate(String templateBody, Object model) in c:\Badr\Service\Implementation\EmailService.cs:line 21 at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) at Service.Implementation.EmailService.SendSingleEmail(String from, String name, String[] to, String subject, String templateBody, Object model, EmailSendMethod sendMethod) in c:\Badr\Service\Implementation\EmailService.cs:line 32 at CallSite.Target(Closure , CallSite , EmailService , String , String , String[] , String , String , Object , EmailSendMethod ) at System.Dynamic.UpdateDelegates.UpdateAndExecute8[T0,T1,T2,T3,T4,T5,T6,T7,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7) at Service.Implementation.EmailService.SendSingleEmail(String from, String name, String to, String subject, String templateBody, Object model, EmailSendMethod sendMethod) in c:\Badr\Service\Implementation\EmailService.cs:line 27 at Service.Implementation.UserEmailService.SendLicenseToUser(Guid token) in c:\Badr\Service\Implementation\UserEmailService.cs:line 86 at Web.Controllers.PurchaseController.CreatePurchaseAndSendEmail(IEnumerable`1 cartItems) in c:\Badr\Web\Controllers\PurchaseController.cs:line 759

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Please help me what should I do?

Was it helpful?

Solution

I looked into your stack trace and looks like it trying to load System.Web.Razor, Version=1.0.0.0 not System.Web.Razor, Version=2.0.0.0 so please try to check references in Web.config files you can also try to deploy your site with System.Web.Razor.dll (select always copy) maybe this help

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top