When I Use VS2015 and Develop MVC3 Program, there have been some strange problems - asp.net-mvc-3

There is a MVC3 program developed and compile using VS2012. It's OK and deployed is also OK.
But when I use VS2015 compile,http://i.stack.imgur.com/eMep6.png,not error,just warning。
but when deploy,It can't run.The error http://i.stack.imgur.com/Jgr4k.png.The error text is
[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=1.0.0.0, Culture=neutral, PublicKeyToken=null' in the context 'Default' at location 'C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\7c2060f6\6145b34e\assembly\dl3\9036b7c7\fc8023c0_73fecb01\System.Web.WebPages.Razor.DLL'.
So,I Know I should be good to learn English, but now what should I do?
some Solution,but did not succeed: http:// www.cnblogs.com/shanyou/archive/2012/12/23/2830367.html
http:// www.cnblogs.com/highend/archive/2011/04/20/aspnet_mvc3_the_project_debug_in_mvc3source.html
This is my razor version:
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>

Mvc3 is supported till VS2010.I use VS2010SP1 btw.
You have to choose if you want to use Mvc3 or VS2015

Related

How to resolve assembly conflict in Visual Studio 2013 web app project?

I have inherited a web app which reports the following assembly conflict when I try to build it under Visual Studio 2013;
There was a conflict between "System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
"System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was chosen because it was primary and "System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35" was not.
References which depend on "System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\System.Web.Mvc.dll].
C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\System.Web.Mvc.dll
Project file item includes which caused reference "C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 4\Assemblies\System.Web.Mvc.dll".
System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
References which depend on "System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35" [].
C:\Users\Administrator\Source\Repos\eRTQ\Software\web\ThirdPartyDll\MIM.Framework.Unity.dll
Project file item includes which caused reference "C:\Users\Administrator\Source\Repos\eRTQ\Software\web\ThirdPartyDll\MIM.Framework.Unity.dll".
MIM.Framework.Unity, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
MIM.Core.ServiceHosts, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL
C:\Users\Administrator\Source\Repos\eRTQ\Software\web\ThirdPartyDll\Microsoft.Web.Mvc.FixedDisplayModes.dll
Project file item includes which caused reference "C:\Users\Administrator\Source\Repos\eRTQ\Software\web\ThirdPartyDll\Microsoft.Web.Mvc.FixedDisplayModes.dll".
Microsoft.Web.Mvc.FixedDisplayModes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL
The Web.config contains this with respect to that assembly;
<compilation debug="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
</assemblies>
</compilation>
and
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.1"/>
</dependentAssembly>
I've tried removing and re-adding the assembly reference. That doesn't seem to change anything.
I can change the version in Web.config from '4.0.0.1' to '4.0.0.0', and that eliminates the warning, but is it the right thing to do?
Ideas?

Compilation Error: "higher version than referenced assembly "

I got error on my view page so I updated my visual studio to mvc4, though I am working on mvc3. I 1st updated using NuGet but it don't works so, I updated through standalone MVC4. so it worked. But when I tried to run MVC3 project it gives me following Error:
CS1705: Assembly 'MVC3Project, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' uses 'System.Web.Mvc, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher
version than referenced assembly 'System.Web.Mvc, Version=3.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35'
Can anyone help me with this?
Inside the web.config file in the Views folder there is the host element under system.web.webPages.razor
This should be as follows for an MVC3 project:
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
While for MVC4 it is:
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
You also need to check the pages element is as follows for MVC3
<pages
validateRequest="false"
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
and the sectionGroup element:
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
In the main web.config in the root directory of the project you need to make sure that the assemblies element is as follows:
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
There are more changes to make - best bet is to look at the web.config files for an MVC3 project and an MVC4 project and remove the stuff that shouldn't be there in yours.
I had the exact same problem with a later version of MVC. After I updated all my packages through Nugget, the problem is resolved.
The following worked for me
Install-Package Microsoft.AspNet.Web.Optimization
The worked solution for me i deleted the reference in project which gives error.
Reinstall that again with right click project -> add references --> search the name of Assembly then add that again.
for this question you have to delete System.Web.Mvc under first project references and click project -> add references --> Search System.Web.Mvc (you will see that is 4.0.0.0 now) install it.
you can download System.Web.Mvc.dll with version that you are looking for then :
Reference -> add ->browse and select ur file.
this solution worked for me !!
Good luck

MVC 3 assembly conflict How to

Every time I download some open source or paid MVC3 app I get some assembly conflicts, ie: missing assemblies, wrong versions etc. So I figure I should ask a more general question:
In a typical project you have a folder called References and all assemblies seem to be in that folder, with their version numbers and Copy To Local options etc.
However out of the 10-20 references in that folder I often find just a few in the web.config.
I the latest case of this annoying mixup I have in web.config:
<compilation debug="false" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
I get an error that project trying to load System.Web.Helpers, Version=1.0.0.0 - it's not found.
In the References folder the System.Web.Helpers referenced is version 2.0.0 and it's not possible to change this version number as it's greyed out. Changing to Specific Version doesn't change anything.
Question:
Why are there the 4 references in Web.config? Why not just the references folder?
Why do i often find a partial number of assembly tags in web.config instead of none or alternatively all the references seen under the References project folder?
Thanks,
Maybe try to re-install MVC3? Those references in the Web.config are ok, as they should be...
Here is my Web.config, in that part....
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />

how to resolve runtime error in mvc3 razor view (Assembly 'MvcApplication2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null')

I want to create a mvc3 web razor application in visual studio 2010 professional. I added mvc3 web project with razor view but when i compile it it gives error of MVC.WEB.dll older version. then i updated mvc.web.dll to version 4 and web.mvc.webpages to version 2 in my refference assemblieis.
I already added the web.config file configurations when it gives compile time error as show below
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
</assemblies>
</compilation>
but now it not give the compile time error as shown below.
Assembly 'MvcApplication2, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
Please help me to resolve this matter.
I want to create a mvc3 web razor application
and then
i updated mvc.web.dll to version 4
what?
Exception ... which has a higher version than referenced assembly ...
Try to remove reference from project references (left click on System.Web.Mvc and press delete), then References -> Add reference sort by name on first tab and select System.Web.Mvc with 4.0.0.0 in second column (version).
Under the References you will find the System.Web.Mvc referenced
remove this reference and add a new reference of higher version i.e 4.x

Upgrade to 4.0: The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?)

I recently upgraded my solution from .net framework 3.5 to 4.0. All good except it gives me some errors in my website project.
The type or namespace name 'Linq' does not exist in the namespace 'System'
(are you missing an assembly reference?)
The type or namespace name 'Linq' does not exist in the namespace 'System.Xml'
(are you missing an assembly reference?)
The type or namespace name 'Script' does not exist in the namespace 'System.Web'
(are you missing an assembly reference?)
Here is what my web.config looks like:
<add assembly="System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Data.DataSetExtensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<!--vjslib is needed for Google Transit-related code-->
<add assembly="vjslib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="Infragistics35.WebUI.Shared.v10.2, Version=10.2.20102.1011, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"/>
<add assembly="Infragistics35.WebUI.UltraWebGrid.v10.2, Version=10.2.20102.1011, Culture=neutral, PublicKeyToken=7dd5c3163f2cd0cb"/>
<add assembly="Infragistics35.WebUI.UltraWebTab.v10.2, Version=10.2.20102.1011, Culture=neutral, PublicKeyToken=7DD5C3163F2CD0CB"/>
<add assembly="Infragistics35.Web.v10.2, Version=10.2.20102.1011, Culture=neutral, PublicKeyToken=7DD5C3163F2CD0CB"/>
<add assembly="System.Web.Mobile, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>
<add assembly="mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
<add assembly="System.Xml.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
Why is it not able to find LINQ reference when i say using System.Linq or System.Xml.Linq? What am i missing here?
--Edit--
This happens only in website project. Other class libraries work fine.
I have a ASP.NET 3.5 WebSite project which I've tried to upgrade to .NET v4. Got the error.
My solution:
Go to WebSite project property pages and set it back to . NET v3.5
Compile and see all is OK
Switch it back to .NET v4
Compile and see all is OK
Have you chose the right framework. I think in your project file on the first tab ".NET Framework 4 Client Profile" is chosen. Take ".NET Framework 4"

Resources