Complications when upgrading from ASP MVC 3 Preview 1 to beta - asp.net-mvc

I have just upgraded my ASP MVC 3 application from the preview to the beta version.
In preview everything worked fine, but as soon as I upgraded weird things started to happen.
I get this error message:
Compiler Error Message: CS0234: The
type or namespace name 'Helpers' does
not exist in the namespace
'System.Web' (are you missing an
assembly reference?)
Source File: c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\1512250b\962d050c\App_Web_index.cshtml.a8d08dba.kncxiw31.0.cs Line: 19
I have tried to completly rebuild the application, and to clear the temporary asp.net files, but nothing works. My solution builds successfully, no errors while building. But when i try to open the website, I get this error.
These are my referenced dll's:
Version Information: Microsoft .NET
Framework Version:4.0.30319; ASP.NET
Version:4.0.30319.1
Screenshot of the error message:
Any thoughts?

After intense searching I found some answers in the ASP.NET MVC 3 release notes. There is a section called Upgrading an ASP.NET MVC 2 Project to ASP.NET MVC 3 which tell you what to do:
Add the two following lines into your <assemblies> section in your web.config:
<add assembly="System.Web.WebPages, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31BF3856AD364E35" />

The problem is that you need to set the Copy Local property to true on the System.Web.Helpers reference.

Make sure that the System.Web.Mvc assembly points to the correct version:
C:\Program Files\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll
and that System.Web.Helpers also:
C:\Program Files\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Helpers.dll
In Beta 3, System.Web.Helpers is a separate download so make sure you've installed AspNetWebPages.msi.

Related

Trying to Upgrade froM MVC3 to MVC4, all ok bar one component which is still referencing 3.0.0.0

I have upgraded my MVC3 application using the Nuget UpgradeFromMvc3ToMvc4 which has worked fine, except for one component. I did uninstall the V3 of this "MvcSiteMapProvider" component before upgrading, and then installed "MvcSiteMap Core V4" after the MVC4 upgrade.
Ther error I get is:
Error 41 Assembly 'MvcSiteMapProvider, Version=4.6.18.0,
Culture=neutral, PublicKeyToken=1923abe4657913cc' 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'
d:\..\MvcSiteMapProvider.MVC4.Core.4.6.18\lib\net45
\MvcSiteMapProvider.dll
There is no reference to 3.0.0.0 in my solution. I have done a "find" in "all files". So am confused.
Any help appreciated. Thanks.
Drop refference to System.Web.MVC and readd it.
Sometimes this just happends.

EPPlus The type or namespace name 'OfficeOpenXml' could not be found (are you missing a using directive or an assembly reference?)

Hi I am using EPPlus to create excel in c# 2.0. I have added the reference of "EPPlus.dll" and also added
using OfficeOpenXML;
but when i am trying to run the solution its giving the follwoing error.
Error:
The type or namespace name 'OfficeOpenXml' could not be found (are you missing a using directive or an assembly reference?)
Warning 1:
The primary reference "EPPlus, Version=3.1.3.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the framework assembly "WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "EPPlus, Version=3.1.3.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL" or retarget your application to a framework version which contains "WindowsBase, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35".
Warning 2:
The primary reference "EPPlus, Version=3.1.3.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL" could not be resolved because it has an indirect dependency on the framework assembly "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" which could not be resolved in the currently targeted framework. ".NETFramework,Version=v2.0". To resolve this problem, either remove the reference "EPPlus, Version=3.1.3.0, Culture=neutral, PublicKeyToken=ea159fdaa78159a1, processorArchitecture=MSIL" or retarget your application to a framework version which contains "System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089".
Thanks in advance..
This solved the problem for me :
Errors on EPPlus
just change the target of your proyect from ".Net 4.0 Client Profile" to just ".Net 4.0"
Rolling back to a prior version worked for me.
This could happen when you migrate project from one computer to another. The solution in my case was
Open the project/website in Visual Studio
Save it as solution (if it is website) - important
Go to Nuget for this solution. It will give you an error that some plugs are installed incorrect and needs to be restored. Click restore button but it might actually not work
Check EPPLUS in the nuget, select properties and uncheck from solution to uninstall it.
Reinstall it again. This should fix it.
Even,I had this type of error in past.So,what you have to do to solve this error.
Firstly, you have check to EPPLUS.dll in bin folder.If you will not see in your bin folder than add it .
secondly,if you see than ,right click on reference folder/add reference/click on browse/add EPPLUS.dll
If you don't have that download from below link:enter link description here
The error was told that the epplus has an indirect reference to the windowbase 3.0 which do not included in .net framework 2.0 then i manage to find that dll located in
"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0\WindowsBase.dll". thank to this question WindowsBase Version 3.0.0.0 in Global Assembly Cache
So i just referenced that dll to my project and the error was gone. this cloud be help.

Problems related to Microsoft HTTP Client Libraries v2.1.10 NuGet update

Note: This question was totally rewritten several days after it was originally posted.
I have an ASP.NET MVC app developed in VS 2012, deployed to Azure. The original projects were created from the ASP.NET MVC 4 project template.
NuGet recently started showing a whole slew of updated packages from Microsoft. One of those updates, Microsoft HTTP Client Libraries v2.1.10, causes serious problems when it is installed.
It installs MicrosoftBcl.Build, which is not compatible with my Azure project (see this SO question for the problem and its solution).
It causes a whole slew of "incompatible DLL" problems (see below).
This raises several burning questions:
My MVC app is just a website. It just runs in a web browser. Do I need this package at all? (E.g., is it used by template code, which would break, possibly subtly, if I remove the package?)
According to the Project Site (http://blogs.msdn.com/b/bclteam/p/httpclient.aspx), there are a couple of newer (albeit beta) versions of this product. I assume I'd see them if I told NuGet to show me non-released versions. Do these versions fix the problems described above?
Here are the warnings I get when I build the solution after installing the updated NuGet package...
1>------ Build started: Project: Ruby, Configuration: Release Any CPU ------
1> All packages listed in packages.config are already installed.
1> No way to resolve conflict between "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". Choosing "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" arbitrarily.
1> Consider app.config remapping of assembly "DotNetOpenAuth.AspNet, Culture=neutral, PublicKeyToken=2780ccd10d57b246" from Version "4.0.0.0" [] to Version "4.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\DotNetOpenAuth.AspNet.4.3.0.13117\lib\net45-full\DotNetOpenAuth.AspNet.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "System.Web.Mvc, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "3.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll] to Version "4.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "System.Web.Razor, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Razor.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "WebGrease, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [] to Version "1.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\WebGrease.1.3.0\lib\WebGrease.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "System.Web.WebPages.Razor, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Razor.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "Microsoft.Data.OData, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "5.2.0.0" [] to Version "5.5.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.Data.OData.5.5.0\lib\net40\Microsoft.Data.OData.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "System.Web.WebPages, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "DotNetOpenAuth.Core, Culture=neutral, PublicKeyToken=2780ccd10d57b246" from Version "4.0.0.0" [] to Version "4.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\DotNetOpenAuth.Core.4.3.0.13117\lib\net45-full\DotNetOpenAuth.Core.dll] to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "System.Web.WebPages.Deployment, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Deployment.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Deployment.dll] to solve conflict and get rid of warning.
1>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly.
1> Ruby -> C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\Ruby\bin\Ruby.dll
2>------ Build started: Project: Ruby.Azure, Configuration: Release Any CPU ------
3>------ Publish started: Project: Ruby.Azure, Configuration: Release Any CPU ------
3>C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.Bcl.Build.1.0.7\tools\Microsoft.Bcl.Build.targets(220,5): warning : All projects referencing Ruby.csproj must install nuget package Microsoft.Bcl.Build.
3> No way to resolve conflict between "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" and "System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35". Choosing "System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" arbitrarily.
3> Consider app.config remapping of assembly "DotNetOpenAuth.AspNet, Culture=neutral, PublicKeyToken=2780ccd10d57b246" from Version "4.0.0.0" [] to Version "4.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\DotNetOpenAuth.AspNet.4.3.0.13117\lib\net45-full\DotNetOpenAuth.AspNet.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "System.Web.Mvc, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "3.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll] to Version "4.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.Mvc.4.0.30506.0\lib\net40\System.Web.Mvc.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "System.Web.Razor, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Razor.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.Razor.2.0.30506.0\lib\net40\System.Web.Razor.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "WebGrease, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [] to Version "1.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\WebGrease.1.3.0\lib\WebGrease.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "System.Web.WebPages.Razor, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Razor.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "Microsoft.Data.OData, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "5.2.0.0" [] to Version "5.5.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.Data.OData.5.5.0\lib\net40\Microsoft.Data.OData.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "System.Web.WebPages, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "DotNetOpenAuth.Core, Culture=neutral, PublicKeyToken=2780ccd10d57b246" from Version "4.0.0.0" [] to Version "4.3.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\DotNetOpenAuth.Core.4.3.0.13117\lib\net45-full\DotNetOpenAuth.Core.dll] to solve conflict and get rid of warning.
3> Consider app.config remapping of assembly "System.Web.WebPages.Deployment, Culture=neutral, PublicKeyToken=31bf3856ad364e35" from Version "1.0.0.0" [C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Deployment.dll] to Version "2.0.0.0" [C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Deployment.dll] to solve conflict and get rid of warning.
3>C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1605,5): warning MSB3247: Found conflicts between different versions of the same dependent assembly.
3> Transformed Web.config using C:\Users\Robert\Documents\SBSoftware\SCM\Ruby\Ruby\Web.Release.config into obj\Release\TransformWebConfig\transformed\Web.config.
3>Ruby(0,0): warning WAT153: The web project 'Ruby' is dependent on the following MVC assembly: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll. MVC assemblies must be added to the package or installed on the virtual machine for your web role. For more details about this, see the following help page: http://go.microsoft.com/fwlink/?LinkId=218227.
3>Ruby(0,0): warning WAT153: The web project 'Ruby' is dependent on the following MVC assembly: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.Razor.dll. MVC assemblies must be added to the package or installed on the virtual machine for your web role. For more details about this, see the following help page: http://go.microsoft.com/fwlink/?LinkId=218227.
3>Ruby(0,0): warning WAT153: The web project 'Ruby' is dependent on the following MVC assembly: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Razor.dll. MVC assemblies must be added to the package or installed on the virtual machine for your web role. For more details about this, see the following help page: http://go.microsoft.com/fwlink/?LinkId=218227.
3>Ruby(0,0): warning WAT153: The web project 'Ruby' is dependent on the following MVC assembly: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.dll. MVC assemblies must be added to the package or installed on the virtual machine for your web role. For more details about this, see the following help page: http://go.microsoft.com/fwlink/?LinkId=218227.
3>Ruby(0,0): warning WAT153: The web project 'Ruby' is dependent on the following MVC assembly: C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Deployment.dll. MVC assemblies must be added to the package or installed on the virtual machine for your web role. For more details about this, see the following help page: http://go.microsoft.com/fwlink/?LinkId=218227.
You can use binding redirects in your web.config file to solve issues.
For example, for line:
Consider app.config remapping of assembly "DotNetOpenAuth.AspNet, Culture=neutral, PublicKeyToken=2780ccd10d57b246" from Version "4.0.0.0" [] to Version "4.3.0.0"
Add in Web.config:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet"
publicKeyToken="2780ccd10d57b246"
culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0-4.3.0.0"
newVersion="4.3.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
and so on... For each dll that creates exception add additional dependentAssembly node.
One situation which causes this error is running the Azure package oder publish commands without having done a clean rebuild for the same configuration (e.g. Release) before.
This fixed it for me:
Reinstall the WindowsAzure.Storage NuGet package by running the following command on the NuGet Package Manager Console:
Update-Package –reinstall WindowsAzure.Storage
Rebuild the MVC web application project (Debug and Release).
If this does not help you could set the "MSBuild project build output verbosity" under TOOLS -> Options -> "Projects and Solutions" -> "Build and Run" to "Diagnostic" and check what causes the Assembly conflict (e.g. look for "Project file item includes which caused reference").
You need to update/create an app.config file with the redirects as mentioned here:
https://cpaterson.wordpress.com/2014/03/28/found-conflicts-between-different-versions-of-assembly-consider-app-config-remapping-of-assembly/

Telerik.Web.Mvc.UI intellisense doesn't work

I have a Class Library plugin for nopCommerce that acts like a MVC3 application and in the Index.cshtml I want to use the Html.Telerik().Grid<MyModel>(Model) and added in my Index.cshtml this #using Telerik.Web.Mvc.UI and it points that it's not found, but when I run the application I don't get an error saying that I don't have the references for that library and compiles my code fine, but I don't have intellisense for the Telerik library, also I added <add namespace="Telerik.Web.Mvc.UI" /> in my root web.config Class Library project and still don't have intellisense.
What I'm doing wrong ?
I found how to resolve the issue:
1. using gacutil.exe to install the assembly in cmd like this c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\x64>gacutil.exe /i Telerik.Web.Mvc.dll
2. finding the the PublickKeyToken for the assembly in cmd with gacutil.exe like this c:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\NETFX 4.0 Tools\x64>gacutil.exe /l Telerik.Web.Mvc
3. adding in my Class Library project web.config file the assembly like this:
<add assembly="Telerik.Web.Mvc, Version=2012.1.214.340, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
</assemblies>
</compilation>
4. adding the namespace in the web.config like this:
<add namespace="Telerik.Web.Mvc.UI" />
</namespaces>
</pages>
5. save, build, close visual studio, open again

Could not load assembly WebPages.Deployment version 2 at host?

I have a ASP.NET MVC 2 website (VS2010) that I have upgraded to ASP.NET MVC 3 (VS2012) and this works fin on local IIS7 but when publishing it I get this exception on host :
Could not load file or assembly 'System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
After some seartch I found this that states that I should set CopyLocal on some of the references(inlcuding the System.Web.WebPages) and also use the publish tool in VS2012, but this generated the following exception?
Could not load file or assembly 'System.Web.WebPages.Deployment, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
And I can´t find any Deployment dll to set copyLocal?
How could I solve this?
Have a read of http://joel.net/getting-asp.net-mvc-3-working-on-discountasp.net
You need to add a reference to System.Web.WebPages.Deployment and set that also to CopyLocal.

Resources