If you encounter a version problem again, record it, forget it, and forget it.

Source: Internet
Author: User

If you encounter a version problem again, record it, forget it, and forget it.

It took a long time to find the solution. It took more than two hours! Record again, Memo!

Problems in ASP. net mvc may occur due to two reasons:

  1. I have referenced the master program High Version dll in the newly created Project. The versions are inconsistent.

  2. A series of problems occurred during version upgrade between MVC4 and MVC5

1. System. Web. WebPages. Razor. Configuration. HostSection version

[A] System. Web. WebPages. Razor. Configuration. HostSection cannot be forcibly converted to [B] System. Web. WebPages. Razor. Configuration. HostSection. Type A is derived from "System. web. webPages. razor, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35 "(in the Context" Default "," 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 is derived from "System. web. webPages. razor, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35 "(in the Context" Default "," C: \ Windows \ Microsoft. net \ assembly \ GAC_MSIL \ System. web. webPages. razor \ v4.0 _ 2.0.0.0 _ 31bf3856ad364e35 \ System. web. webPages. razor. dll ).

 

Solution:Configure Web. config in view<Section name = "host" type = "System. web. webPages. razor. configuration. hostSection, System. web. webPages. razor, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = 31BF3856AD364E35 "requirePermission =" false "/>

2. System. Web. WebPages. Razor. Configuration. RazorPagesSection

[A] System. Web. WebPages. Razor. Configuration. RazorPagesSection cannot be forcibly converted to [B] System. Web. WebPages. Razor. Configuration. RazorPagesSection. Type A is derived from "System. web. webPages. razor, Version = 1.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35 "(in the Context" Default "," 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 is derived from "System. web. webPages. razor, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = 31bf3856ad364e35 "(in the Context" Default "," C: \ Windows \ Microsoft. net \ assembly \ GAC_MSIL \ System. web. webPages. razor \ v4.0 _ 2.0.0.0 _ 31bf3856ad364e35 \ System. web. webPages. razor. dll ).

 

Solution:Configure Web. config in view<Section name = "pages" type = "System. web. webPages. razor. configuration. razorPagesSection, System. web. webPages. razor, Version = 2.0.0.0, Culture = neutral, PublicKeyToken = 31BF3856AD364E35 "requirePermission =" false "/>


3. System. Web. Mvc. MvcWebRazorHostFactory version Problems

The expression "System. Web. Mvc. MvcWebRazorHostFactory" cannot be used to return the type "System. Web. WebPages. Razor. WebRazorHostFactory"

Solution:Configure Web. config under the project<Runtime> <assemblyBinding xmlns = "urn: schemas-microsoft-com: asm. v1"> <! -- <DependentAssembly> <assemblyIdentity name = "System. web. mvc "publicKeyToken =" 31bf3856ad364e35 "/> <bindingRedirect oldVersion =" 1.0.0.0-2.0.0.0 "newVersion =" 3.0.0.0 "/> </dependentAssembly> --> <dependentAssembly> <assemblyIdentity name =" System. web. helpers "publicKeyToken =" 31bf3856ad364e35 "/> <bindingRedirect oldVersion =" 1.0.0.0-2.0.0.0 "newVersion =" 2.0.0.0 "/> </dependentAssembly> <assemblyIdentity name =" System. web. mvc "publicKeyToken =" 31bf3856ad364e35 "/> <bindingRedirect oldVersion =" 1.0.0.0-4.0.0.0 "newVersion =" 4.0.0.0 "/> </dependentAssembly> <assemblyIdentity name =" System. web. webPages "publicKeyToken =" 31bf3856ad364e35 "/> <bindingRedirect oldVersion =" 1.0.0.0-2.0.0.0 "newVersion =" 2.0.0.0 "/> </dependentAssembly> </assemblyBinding></Runtime>

 

You can leave a message on the public account to obtain related resources or ask other questions.If you have excellent original technical articles, you can contribute articles and share them with others to earn a reward!

Scan to get more development resources:

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.