Assembly conflict resolution for ASP. NET MVC native assembly and GAC
Source: Internet
Author: User
<span id="Label3"></p><p><p>A project that was upgraded from asp. NET MVC 3 to ASP 4 has the following error:</p></p>A System.Web.WebPages.Razor.Configuration.HostSection cannot is 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=1.0.0.0, culture=neutral, publickeytoken=null ' in the context ' Default ' at location ' C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary asp. files\root\7c2060f6\6145b34e \assembly\dl3\9036b7c7\fc8023c0_73fecb01\system.web.webpages.razor.dll '.<p><p>This is because the local assembly conflicts with the Gac's assembly because in Web Pages 1.0 He adds a new configuration node within the Config. Web Pages 1.0 Currently in Web. config, I have discovered that a new configuration node has been added, and the path is ~/views/web.config. instead of Web. config.</p></p><p><p><configuration></p></p><p><p><system.web.webpages.razor/> <!--attention to his common system.web</p></p><p><p><system.web/></p></p><p><p>...</p></p><p><p></configuration></p></p><p><p>Modify the ~/views/web.config as Follows:</p></p><pre class="csharpcode"><?xml version=<span class="str">"1.0"?><configuration> <configSections> <sectiongroup name=<span class="str">"system.web.webPages.razor" type=<span class="str">"System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, version=2.0.0.0, culture=neutral, publickeytoken=31bf3856ad364e35 "> <section name=<span class="str">"host" type=<span class="str">"System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, version=2.0.0.0, culture=neutral , Publickeytoken=31bf3856ad364e35 "requirepermission=<span class="str">"false"/> <section name=<span class="str">"pages" type=<span class="str">"System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, version=2.0.0.0, culture= neutral, publickeytoken=31bf3856ad364e35 "requirepermission=<span class="str">"false"/> </sectionGroup> </configSections> <system.web.webPages.razor>
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.