Question

There is a solution with multiple projects, one of them is using RazorEngine (which depends on System.Web.Razor 3.0.0.0) and the other is ASP.NET MVC 4 project, which uses System.Web.Razor 2.0.0.0.

All works fine, until I start using classes from the first project in my MVC project. Then I get this error:

{"Could not load file or assembly 'System.Web.Razor, Version=3.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)":"System.Web.Razor, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35"}

Is there any way to use the both versions simultaneously? Upgrading the whole solution to Razor 3 is not an option, as it breaks things.

Was it helpful?

Solution

Since .NET doesn't support loading more than one version of the same assembly into any Application Domain, it's not going to be running in the same application pool. With some trickery you might be able to get things working using two separate virtual directories, one hosting the old solution, one hosting the new.

As long as your application doesn't rely on Session state that might be the simplest thing to get working. As long as you then make sure both applications have the same MachineKeys configured. It'd be a sort of "Web farm Deployment".

If you are using Session State, you might need to configure session to be stored out-of-process in the state service or in SQL Server.

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