Closed JonEHolland closed 11 years ago
I have the same issue, I've just migrated my MVC4 which uses system.web.razor 2.0.0.0 to use Postal, which uses RazorEngine. Unfortunately after I deploy my project to its Azure environment I get:
"Could not load type 'System.Web.Razor.Parser.SyntaxTree.CodeSpan' from assembly 'System.Web.Razor, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'".
I'm also using the same bindingRedirect.
So I'm a bit stuck at the moment and looking to rollback to MVC3.
Any ideas?
I've the same issue
They removed some classes and refactored others in v2 - which breaks RazorEngine :(
I'm having the same problem. Is there any workaround for it?
The only way I could find was to remove the redirect to WebPages 2.0 from web.config placed there by NuGet - so far no problems but I'm not using any other packages that require this assembly
Where is that redirect you are talking about? And for that i need to include web pages 2.0 and 1.0 assemblies on the solution?
Yes. Be careful because nuget seems to re-add it if you change packages
Somehow the XML is not showing up - in web.config there's a bindingRedirect for 0-2 of System.Web.Razor to 2.0
PS: its System.Web.Razor, I made a mistake earlier
So are there still no work-arounds or fixes for this issue yet?
I found one! http://stackoverflow.com/a/10936596/165656
@georgiosd does it look like the app.config step is missing from that submission?
The XML was in the answer but wasn't showing... fixed that :)
I think this problem is becoming more and more pressing, especially with the release of asp.net mvc 4. I've looked into what it'd take to upgrade to the latest version of razor, but I don't have a deep enough understanding of the compiler internals.
I've got most of the unit tests passing, with the exception of the ones that explicitly declare the @model
. It looks like this isn't a built in feature for razor and the existing code uses a keyword extension. The problem is that API has completely changed...
I looked through the asp.net mvc code to see how they do it, but I can't find where they're doing it... Any thoughts?
Have you tried posting at the http://aspnetwebstack.codeplex.com/ forums? The MS folks are usually quite good at engaging with the community.
Time to upgrade RazorEngine to use System.Web.Razor 2.0?
There is some work to do, as System.Web.Razor v1 and v2 aren't API-compatible, there are some under the hood changes that would break the current version of RazorEngine. I'm investigating either a switch to v2, or looking to provide two versions, one for v1 and v2 compatability.
Any way to help? Is there a branch of a v2 compatible version of RazorEngine we could use?
See my SO post above for a temp fix.
I have an experimental fork of the project that I'm currently using that I've upgraded to v2.
Hi coxp is your v2 compatible version available at all? Thanks Mark
just saw this: https://github.com/Antaris/RazorEngine/issues/71
Hi,
You can build the dll using my fork but there isn't a NuGet package available. I'm using this in production but YMMV.
https://github.com/coxp/RazorEngine
This is using the Razor 2 dll so you get support for the new features like null attributes.
There are no tests though that's why I haven't made a pull request.
v3.1.0 introduced Razor 2 compatability, available on Nuget.
Trying to get RazorEngine to work again after upgrading a project from System.Web.Razor 1.0.0 to System.Web.Razor 2.0.0 (In MVC 4 Beta).
At first I was getting:
[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)] RazorEngine.Compilation.DefaultCompilerServiceFactory.CreateCompilerService(Language language) +0 RazorEngine.Templating.TemplateService.CreateTemplateType(String razorTemplate, Type modelType) +1143 RazorEngine.Templating.TemplateService.CreateTemplate(String razorTemplate, T model) +166 RazorEngine.Templating.TemplateService.Parse(String razorTemplate, T model) +187 RazorEngine.Razor.Parse(String razorTemplate, T model) +184
I added a binding redirect to the app:
Now, I get:
[MissingMethodException: Method not found: 'System.Collections.Generic.Dictionary
2<System.String,BlockParser> System.Web.Razor.Parser.CSharpCodeParser.get_RazorKeywords()'.] RazorEngine.Compilation.CSharp.CSharpCodeParser..ctor() +0 RazorEngine.Compilation.RazorEngineHost.DecorateCodeParser(ParserBase incomingCodeParser) +138 System.Web.Razor.RazorTemplateEngine.CreateParser() +57 System.Web.Razor.RazorTemplateEngine.GenerateCodeCore(ITextDocument input, String className, String rootNamespace, String sourceFileName, Nullable
1 cancelToken) +79 System.Web.Razor.RazorTemplateEngine.GenerateCode(TextReader input, String className, String rootNamespace, String sourceFileName, Nullable1 cancelToken) +126 System.Web.Razor.RazorTemplateEngine.GenerateCode(TextReader input) +85 RazorEngine.Compilation.CompilerServiceBase.GetGeneratorResult(RazorEngineHost host, String template) +187 RazorEngine.Compilation.CompilerServiceBase.GetCodeCompileUnit(String className, String template, ISet
1 namespaceImports, Type templateType, Type modelType) +982 RazorEngine.Compilation.DirectCompilerServiceBase.Compile(TypeContext context) +442 RazorEngine.Compilation.DirectCompilerServiceBase.CompileType(TypeContext context) +189 RazorEngine.Templating.TemplateService.CreateTemplateType(String razorTemplate, Type modelType) +1526 RazorEngine.Templating.TemplateService.CreateTemplate(String razorTemplate, T model) +166 RazorEngine.Templating.TemplateService.Parse(String razorTemplate, T model) +187 RazorEngine.Razor.Parse(String razorTemplate, T model) +184This is with the latest RazorEngine nuget package.
Is RazorEngine not compatible with System.Web.Razor 2.0.0?