zoukankan      html  css  js  c++  java
  • Asp.Net MVC in Visual Studio 11 Beta Not Working Upgrading an ASP.NET MVC 3 Project to ASP.NET MVC 4

    Compiler Error Message: CS0433: The type 'System.Web.WebPages.HelperPage' exists in both 'c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.WebPages\v4.0_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.dll' and 'c:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Web.WebPages\v4.0_1.0.0.0__31bf3856ad364e35\System.Web.WebPages.dll'

    I tried uninstalling the Beta (and Developer Preview), and reinstalling the Beta as admin.  Nothing seems to work, I still get the same errors above.

    I was able to run the second project previously in the Developer Preview.

    ASP.NET MVC 4 can be installed side by side with ASP.NET MVC 3 on the same computer, which gives you flexibility in choosing when to upgrade an ASP.NET MVC 3 application to ASP.NET MVC 4.

    The simplest way to upgrade is to create a new ASP.NET MVC 4 project and copy all the views, controllers, code, and content files from the existing MVC 3 project to the new project and then to update the assembly references in the new project to match the old project. If you have made changes to the Web.config file in the MVC 3 project, you must also merge those changes into the Web.config file in the MVC 4 project.

    To manually upgrade an existing ASP.NET MVC 3 application to version 4, do the following:

      1. In all Web.config files in the project (there is one in the root of the project, one in the Views folder, and one in the Views folder for each area in your project), replace every instance of the following text (note: System.Web.WebPages, Version=1.0.0.0 is not found in projects created with Visual Studio 2012):
    System.Web.Mvc,Version=3.0.0.0
    System.Web.WebPages,Version=1.0.0.0
    System.Web.Helpers,Version=1.0.0.0
    System.Web.WebPages.Razor,Version=1.0.0.0

    with the following corresponding text:

    System.Web.Mvc,Version=4.0.0.0
    System.Web.WebPages,Version=2.0.0.0
    System.Web.Helpers,Version=2.0.0.0,
     
    System.Web.WebPages.Razor,Version=2.0.0.0,
      1. In the root Web.config file, update the webPages:Version element to "2.0.0.0" and add a newPreserveLoginUrl key that has the value "true":
    <appSettings>
     
    <addkey="webpages:Version"value="2.0.0.0"/>
     
    <addkey="PreserveLoginUrl"value="true"/>
    </appSettings>
    1. In Solution Explorer, right-click on the References and select Manage NuGet Packages. Search for Microsoft.AspNet.Mvc and install the Microsoft ASP.NET MVC 4 (RC) package. Click OK.
    2. In Solution Explorer, right-click the project name and then select Unload Project. Then right-click the name again and select Edit ProjectName.csproj.
    3. Locate the ProjectTypeGuids element and replace {E53F8FEA-EAE0-44A6-8774-FFD645390401} with {E3E379DF-F4C6-4180-9B81-6769533ABE47}.
    4. Save the changes, close the project (.csproj) file you were editing, right-click the project, and then select Reload Project.
    5. If the project references any third-party libraries that are compiled using previous versions of ASP.NET MVC, open the root Web.config file and add the following three bindingRedirect elements under the configuration section:
      <configuration>
       
      <!--... elements deleted for clarity ...-->
       
       
      <runtime>
         
      <assemblyBindingxmlns="urn:schemas-microsoft-com:asm.v1">
           
      <dependentAssembly>
             
      <assemblyIdentityname="System.Web.Helpers"
                   
      publicKeyToken="31bf3856ad364e35"/>
             
      <bindingRedirectoldVersion="1.0.0.0"newVersion="2.0.0.0"/>
           
      </dependentAssembly>
           
      <dependentAssembly>
             
      <assemblyIdentityname="System.Web.Mvc"
                   
      publicKeyToken="31bf3856ad364e35"/>
             
      <bindingRedirectoldVersion="1.0.0.0-3.0.0.0"newVersion="4.0.0.0"/>
           
      </dependentAssembly>
           
      <dependentAssembly>
             
      <assemblyIdentityname="System.Web.WebPages"
                   
      publicKeyToken="31bf3856ad364e35"/>
             
      <bindingRedirectoldVersion="1.0.0.0"newVersion="2.0.0.0"/>
           
      </dependentAssembly>
         
      </assemblyBinding>
       
      </runtime>
      </configuration>

    http://forums.asp.net/t/1775280.aspx/1

    http://www.asp.net/whitepapers/mvc4-release-notes#_Toc303253806

  • 相关阅读:
    三层架构之解耦
    自动升级 组件
    C语言常量与指针
    ASP.NET MVC Model元数据
    Web层后端权限模块
    java中文排序问题(转)
    JDWP
    bat执行java程序的脚本解析
    jdom dom4j解析xml不对dtd doctype进行验证(转)
    Dom4j SAXReader Constructors
  • 原文地址:https://www.cnblogs.com/Leo_wl/p/2589878.html
Copyright © 2011-2022 走看看