从MVC4迁移到MVC3或将Razor V2更改为V1

时间:2014-01-17 09:14:49

标签: asp.net-mvc razor razor-2

我正在使用MVC4开发一个应用程序,现在我添加了新的软件包“mvcinstalled.mvc3”和“securityGuard”。实施后我得到了一个错误。我知道这两个软件包兼容剃刀版本V1而不适用于V2。任何人都可以建议如何从Razor V2迁移到V1或将完整的应用程序迁移到MVC3?

 [A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to       
 [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A originates from  
 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, 
 PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 
 C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_1.0.0.
 0__31bf3856 
 ad364e35\System.Web.WebPages.Razor.dll'. Type B originates from 
 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral,  
 PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 
 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_2.0.0.0
 __31bf3856ad364e35\System.Web.WebPages.Razor.dll'.
 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: System.InvalidCastException:   
 [A]System.Web.WebPages.Razor.Configuration.HostSection cannot be cast to  
 [B]System.Web.WebPages.Razor.Configuration.HostSection. Type A originates from 
 'System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, 
 PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location 
 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_1.0.0.0
 __31bf3856ad364e35\System.Web.WebPages.Razor.dll'. Type B originates from  
 'System.Web.WebPages.Razor, Version=2.0.0.0, Culture=neutral,  
 PublicKeyToken=31bf3856ad364e35' in the context 'Default' at location    
 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Web.WebPages.Razor\v4.0_2.0.0.0
 __31bf3856ad364e35\System.Web.WebPages.Razor.dll'.

1 个答案:

答案 0 :(得分:0)

我无法解决这个问题,我现在开始在MVC4中开发所有内容,而不是转移到mvc3。