Stuck in ASP.NET MVC DLL HELL, Razor Assembly issue - c#

I'm currently dealing with a problem on a ASP.NET MVC4 Application, I did a change of .NET Framework (from 4.5 to 4 then to 4.5 again) and it updated my NuGet packages so my Web.config is all messed up and i can't get rid of those errors that the YSOD shows me. Can you explain me a bit what can i do to correct those errors ?
Here's the error i get.
[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=2.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_2.0.0.0__31bf3856ad364e35\System.Web.WebPages.Razor.dll'.
Type B originates from 'System.Web.WebPages.Razor, Version=3.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context
'Default' at location
'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET
Files\root\5ccfcdb0\4d5a6f51\assembly\dl3\5f700272\1350df4e_ebe9ce01\System.Web.WebPages.Razor.dll'.

Okay i solved my problem by myself.
I updated manually in the Web.config (from the Views Folder) the configuration to Version=3.0.0.0 and the version of the MvcWebRazorHostFactory (same file) to Version=5.0.0.0

Related

Resource.designer.cs(32713, 4): [CS0433] The type 'Resource' exists in both. ( Maui, build error)

I have separated my Maui project to few libraries.
x.Services, x.Data and x.Core.
After that, I got an error - Resource.designer.cs(32713, 4): [CS0433] The type 'Resource' exists in both 'x.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' and 'x.Data, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'
This error I am getting when I am building a project.
I have deleted obj and bin folders from project and rebuild, but nothing changed.
All namespaces are unique, project versions are same.
Problem was in root namespace! There was not that library namespace, but another. I don't know why, I didn't change it.
Image with location where you can solve that problem

System.Object found in more than one assembly

I've a strange problem at the moment where i sometimes get the following exception:
Type System.Object found in more than one assembly (mscorlib, Version=4.0.0.0, ... and System.Runtime, Version=4.0.0.0, ...)
The app is a classic desktop app which references .NET 4.5 but the main problem is that this only happens sometimes so it's really hard to reproduce.
I think that it allways works if System.Runtime gets not loaded.
But how can figure out who is responsible for loading System.Runtime? Why is this assembly beeing loaded sometimes?
UPDATE:
I think the problem is this assembly: Microsoft.CodeDom.Providers.DotNetCompilerPlatform This assembly internally loads System.Runtime via: Assembly.Load("System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a").Location;
But i've no idea how to solve this problem.
Does anyone have an idea?

Strange MVC Referencing Issue

I have an MVC solution that was 3.0.0.0 but I'm upgrading it to 4.0.0.1. I've upgraded the System.Web.Mvc reference (in the reference folder) and it's dependencies, e.g. updated System.Web.WebPages from 1 to 2.
When I build the project it builds without issue, however when I run the project I get the following error:
Compiler Error Message: CS1705: Assembly 'MobileScanner, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35' which has a higher version than referenced assembly 'System.Web.Mvc, Version=3.0.0.1, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
P.S. Using VS2010, and .Net 4.0
Thanks for your help but I fixed it.
The issue was that there were still references to MVC 3 and some of it's (old) dependencies (System.Web.Razor) in the root web.config and then again in the Views/web.config... once updated it worked a treat.

WebHelper Assembly error using Visual Web Developer 2010 Web Forms

I'm attempting to run a web application from VWD 2010 using Web Forms (Not MVC) but am getting this error message below:
Assembly 'WebHelper, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' uses 'Microsoft.ReportViewer.WebForms, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
In my web.config file, there is this line of code below which I have tried as commented out, and left alone, but neither way makes any difference.
<add assembly="Microsoft.ReportViewer.Common, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
Any suggestions welcome.
Thank you!
I solved this in the end, but how graceful it is yet to be seen. I tried to download the 10.0.0.0 version of the Microsoft.ReportViewer.WebForms dll from Microsoft but I couldn't quite work out where it was saved to, and when I did, It was a word document which didn't really do much for me.
As it happens, my colleague had it on her machine, so I simply copied hers and it put in place on my machine. Added the new reference to my project. Problem solved.

Won't compile after installing: Mcv.Mailer version 1.0 uses Mvc version 4.0, which has higher version than referenced assembly Mvc version 3.0

I installed the nuget package for MvcMailer, found here. Although it didn't (as it says in the tutorial it will) add smtp configuration to web.config, I found the correct smtp configuration here.
I'm using MVC4 in VS2010.
When I compile, I get the following error in the the error list:
Error 1 Assembly 'Mvc.Mailer, 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' c:\Users\Home\Desktop\MVCMusicStore - Copy\packages\MvcMailer.4.0\lib\40\Mvc.Mailer.dll MVCMusicStore
I also get the following warning:
Warning 2 Found conflicts between different versions of the same dependent assembly. MVCMusicStore
I removed the MvcMailer reference and added it again, but it didn't resolve the issue.
Help would be much appreciated.
I'm using Mvc 4, and was installing MvcMailer via the package manager with the following:
install-package MvcMailer
Because I'm using Mvc 4, the following should be used:
install-package MvcMailer3
This has resolved the issue.

Categories