Can not find Web.Config and System.Web.MVC - asp.net-mvc

I am working on an ASP.NET Core MVC, recently I got the following error and could not find web.config or system.web.mvc inside my project to fix the problem. Can anyone help me with the issue?
You must add a reference to assembly 'System.Web.Mvc, Version=5.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

You need to use the correct version of the Syncfusion components designed specifically for Asp.net Core, looks like you were using the old .NET version. https://ej2.syncfusion.com/aspnetcore/documentation/chart

Related

EntityFramework, version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 is incompatible with .net framework 4

I have recently upgraded all solutions in my project to EF6 alpha3 but one of my projects is missing the EntityFramework.dll and EntityFramework.SQLServer.dll references. Naturally this is causing an error when I run the application, but when I try to manually add the references to the solution I get the error message:
"EntityFramework, version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 is incompatible with .net framework 4"
My other solutions' application settings are .net 4 and they are not having this problem. What other setting or problem could be causing this? I am not sure what code or examples to attach here, so please request as needed. Thank you.
EF6 has separate dlls for each .NET Framework version it supports (i.e. .NET Framework 4 and .NET Framework 4.5). When you manually added the reference you probably referenced the dll that is meant for .NET Framework 4.5. The best way to add EF6 to your project is by using nuget. It will install the correct version of the EF6 dll depending on what .NET Framework version you target in your project.

Could not load file or assembly 'System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies

I have ASP.Net MVC 2 and 3 installed. I've downloaded the complete source from github for the Rob Connery MVC Storefront here. I've opened it in VS2010, which ran the conversion wizard. When I launch it though, I get the error in the title, on the following line <li>About</li> which is line 24 in Site.Master. So I'm thinking, ah, this thing is still referencing v1 of MVC, instead of v2. So the first thing I checked is the section of the web.config, thinking that must be where the reference to version 1 of MVC is residing, however, I found the following <add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />. Even in the Project References, the reference properties for System.Web.Mvc show that it is referencing v2.0 from the folder C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 2\Assemblies. Does anyone have advice on where I can find the reference to the v1.0.0.0 of System.Web.Mvc so that I can change this to v2 in order to make the above error go away.
The most probable cause for this exception is that you are referencing some assembly in your project that implicitly depends on System.Web.Mvc 1.0. For example you might be using some DI framework which is compiled against MVC 1. So if you have ensured that in your web.config you have the correct version and that it is the correct version being referenced you might go through all other assemblies that are referenced in your project and see if they don't depend on MVC 1.0.

Issue with Razor MVC3

MVC 3 RC
I registered both System.Web.Razor and System.Web.WebPages.Razor and still have System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup not recognized in my View/web.Config
Intellisence for Razor is not working
What can be wrong with my configuration
Add the assembly "System.Web.WebPages.Razor" to the main Web.config of the application.
For some reason the "ASP.NET MVC 3 Web Application" project template included in the RC1 does not fill it.
<add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
It's not obvious from your question or the comments if you've done it, but in order to have full support for Razor in your system you need to install the runtime and the tooling using the following installer: http://www.microsoft.com/downloads/en/details.aspx?FamilyID=a920ccee-1397-4feb-824a-2dfefee47d54
Just putting the MVC 3 runtime binaries in your application and making changes to web.config is not enough to make Razor IntelliSense work in Visual Studio.
The problem disappeared from the time I removed Resharper

Debugging ASP.NET MVC source?

Trying to debug into ASP.NET MVC 1.0 source, I followed instructions like these, basically remove reference to system.web.mvc from my web project and add the source project I downloaded instead.
Now, I have this problem,
The type 'System.Web.Mvc.FormMethod'
exists in both
'c:\Windows\assembly\GAC_MSIL\System.Web.Mvc\1.0.0.0__31bf3856ad364e35\System.Web.Mvc.dll' and in my AppData\Local\Temp\Temporary
ASP.NET
Files\root\dbcbb149\897fc019\assembly\dl3\796c00fb\f345f2d6_abe3c901\System.Web.Mvc.DLL'
I tried commenting out the following from web.config
<add assembly="System.Web.Mvc, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
but it'll give a difference error
The type 'System.Web.Mvc.Controller'
is defined in an assembly that is not
referenced. You must add a reference
to assembly 'System.Web.Mvc,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'.
Could someone help on what's going wrong and how to fix it. Thank you very much!
Ray.
There is no need to uninstall ASP.NET MVC from GAC! (or any any <assemblyBinding>s) Just follow "Using the ASP.NET MVC source code to debug your app" article step by step.
There are a couple of questions similar to yours:
How can you use ASP.NET MVC build from source rather than the GAC?
MVC. Strongly-typed view difference (MVC sources vs. assembly)
Are the system.web.mvc assemblies in the GAC? you might need to remove them ... this of course could mess up future projects as the project templates will likely assume that they are in the gac.
You could also try using the <assemblyBinding> feature as described here to point the mvc stuff to the version that you are running.
Assuming the fully qualified assembly name for the one you're linking to differs from the one in the GAC, use the <QualifyAssembly> element and specify which assembly you're actually linking to. If not, change your local source to change the MVC assembly you're building to 1.0.0.1 so it is different.
Edit: Double check the howto you linked. It worked for me.
removed the system.web.mvc reference in my project.
Added the System.Web.Mvc project from source.
Comment out the System.Web.Mvc reference in my project's web.config.
modified the System.we.b.mvc's /Views/Web.Config as stated in the howto.
Ran flawlessly.
for the qualify assembly section you want something like this (we do it for SQLite assembly):
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<qualifyAssembly partialName="System.Data.SQLite" fullName="System.Data.SQLite, Version=1.0.60.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
</assemblyBinding>
</runtime>
Have a look at this article for the complete guide on how to setup MVC source.
There are two web.config files you need to update. One is in the MVC project folder and one is in the Views folder. It's likely you forgot to update the latter. Otherwise following the aforementioned article should do it.
A slightly more comprehensive version of Steve Sandersons instructions can be found here.
It explains how you can also include MVC Futures in your debugging.

Using asp.net mvc 2 features with the spark view engine

I am working with an ASP.NET MVC project which was originally started from the CodeBetter.Canvas project - and I'm trying to move to ASP.NET MVC 2. I successfully upgraded my project using Eilon's upgrade tool, moved to VS2010 (although not yet to .NET 4).
The issue I'm having currently is only occurring when using the spark view engine. Here is the relevant bit of code in my View.spark (strongly typed):
${Html.EditorFor(e => e)}
The same bit of code works just fine if I use an .aspx view:
<%= Html.EditorFor(e => e) %>
The major point here being "EditorFor" is new in ASP.NET MVC 2 and in my project I can use that helper in an ASPX view but not a Spark view.
I've tried upgrading Spark to use MVC 2 (as well as MvcContrib and Ninject), thinking maybe it was one of those that was freaking out - but so far no luck - I'm still seeing the same behavior.
Here is the full error message that is thrown from within Spark's BatchCompiler class.
Dynamic view compilation failed.
(0,0): warning CS1701: Assuming
assembly reference 'System.Web.Mvc,
Version=1.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35'
matches 'System.Web.Mvc,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=31bf3856ad364e35', you
may need to supply runtime policy
c:\inetpub\wwwroot[myproject]\CodeBetter.Canvas.Web\Views[MyEntity]\View.spark(9,16):
error CS1061:
'System.Web.Mvc.HtmlHelper' does not
contain a definition for 'EditorFor'
and no extension method 'EditorFor'
accepting a first argument of type
'System.Web.Mvc.HtmlHelper' could be
found (are you missing a using
directive or an assembly reference?)
Here is the Spark related code in my Global.asax:
var settings = new SparkSettings()
.AddNamespace("System")
.AddNamespace("System.Collections.Generic")
.AddNamespace("System.Web.Mvc")
.AddNamespace("System.Web.Mvc.Html")
.AddNamespace("MvcContrib.FluentHtml")
.AddNamespace("CodeBetter.Canvas")
.AddNamespace("CodeBetter.Canvas.Web")
.SetPageBaseType("ApplicationViewPage")
.SetAutomaticEncoding(true);
#if DEBUG
settings.SetDebug(true);
#endif
var viewFactory = new SparkViewFactory(settings);
ViewEngines.Engines.Add(viewFactory);
Also, I am referencing System.Web.Mvc.Html in my spark view as mentioned in another SO answer.
<use namespace="System.Web.Mvc.Html" />
The underlying issue is that a version 1.0.0 assembly is still being referenced somewhere in the project.
Using reflector to examine each assemblies dependencies, I found (if you're starting with CodeBetter.Canvas project) there are three dependent projects that need to be updated to use the 2.0.0 version of system.web.mvc.dll
Spark. Download the latest version
of spark from teamcity and use the
spark.web.mvc2.dll (which references
system.web.mvc.dll 2.0.0) Link to detailed instructions.
MVCContrib. Download the latest version
of MVCContrib (download release, download source) which references the
system.web.mvc.dll 2.0.0.
Ninject. Download the latest version of
ninject and recompile the VS solution
after updating the reference to the 2.0.0
version of system.web.mvc.dll
Now, replace these dependency's assemblies in your project and update the project references if necessary. All should be well.
I recently converted my spark project to asp.net mvc 2. I dont see in what you've written that you've switched from using Spark.Web.Mvc to Spark.Web.Mvc2.
Just to be clear, Spark.Web.Mvc2 is the project that needs to be recompiled with the new System.Web.Mvc assembly.
I had issues with intellisense until i removed all assembly and namespace references from the web.config and put them in the global.spark file and had added the pageBaseType="Spark.Web.Mvc2.SparkView" attribute to the Spark->Pages node in the web.config.
Hope any of that helps.
When you downloaded newest Spark sources, did you rebuild it using MVC 2 assemblies? Did you replace references in Spark project?
Try specifiying the System.Web.Mvc reference in the web.config instead of the Global.ascx.cs file so that you can specify the specific version:
<spark>
<compilation debug="true" defaultLanguage="CSharp">
<assemblies>
<add assembly="System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</assemblies>
</compilation>
</spark>
This should prevent SPARK from working at all if the wrong version of the MVC assembly is being loaded from somewhere.
If the MVC 1.0 Assembly is in the GAC you can clear and reload it as follows:
(from Visual Studio command prompt)
ngen /delete System.Web.Mvc
ngen /delete System.Web.Abstractions
ngen update
Hope this helps,
Jeff French
These are the steps I took to resolve the issue with a new MVC 2 project and Spark 1.1:
Compile against MVC 2.0 - I double checked the references to make sure I was linking to MVC 2 and not MVC 1. Since this was a new project, this was not an issue.
Added System.Web.Mvc.Html - I added System.Web.Mvc.Html to the Spark configuration, to make sure that namespace was added to all views.
In Global.asax.cs Application_Start
var settings = new SparkSettings()
.SetDebug(true)
.SetAutomaticEncoding(true)
.AddAssembly("Web")
.AddNamespace("Web.Model")
.AddNamespace("System.Collections.Generic")
.AddNamespace("System.Linq")
.AddNamespace("System.Web.Mvc")
.AddNamespace("System.Web.Mvc.Html");
This can also be done in the webconfig in the Spark View Engine block.
Add the Typed Model - Make sure you type the Spark View Model. In aspx this is done with the Inherits in the page declaration, like this:
<%# Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master"
Inherits="System.Web.Mvc.ViewPage<MyModelType>" %>
in Spark:
<viewdata model="MyModelType" />
I tried a lot of things mentioned above but just couldn't get a dependent dll that my views used (and also referenced MVC 1.0.0.0) to use the MVC 2.0.0.0, so here is what fixed it for me...
I downloaded the Spark code and added the following line to the BatchCompiler.cs file in the Compile method:
compilerParameters.CompilerOptions = "/nowarn:1701";

Resources