Problems after migrating VS2013 to VS2015 in MVC - asp.net-mvc

UPDATED QUESTION
I have a project that I've started in VS 2013 and was setup as the following:
MyMainMvcApp (Containing core Functionality)
MyPlugin (Containing plugable customer stuff)
MyPlugin contains some *.cshtml views as embedded resource and some controllers.
In VS2013 I was able open the Views and i had full Razor Intellisense and no issues when compiling.
IN V2015 the Error List is showing a lot of errors like
Feature 'lambda expression' is not available in C# 2. Please use language version 3 or greater.
The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
etc etc
Of course I have all the Assemblies referenced. And the projects even compile.
I believe that VS 2015 is just missing some config stuff in web.config or similar, so that he can resolve the stuff while having the view open in designer.
I have an app.config in MyPlugin project that has been added from Nuget.
I've put the same config stuff as my web.config in there but that didn't help.
As well I copied the MyMainMvcApp\Views\web.config into MyPlugin\Views\web.config that didn't work as well.
Any idea what the issue might be or ideas how to solve it?

I've started MyPlugin as a Class Library in VS 2013 and that worked well. Afterwards I was not able to make MyPlugin work as desired in VS 2015 designer. I've created a new MyPlugin Project as a MVC Project and copied all my code from the old library to the new.
It's a workaround but that solves my VS 2015 problems.

The fact that it's trying to utilize C# 2, is pretty concerning. Make sure your project is targeting the latest version of .NET you feel comfortable with. Since you're using VS2015, go all the way to 4.6 if you like, or if you want something a little more hardened, stick with 4.5.2. Just right-click your project in the Solution Explorer and choose "Properties". Then on the first "Application" tab, change the "Target framework" drop-down to something appropriate.

Related

upgrade asp.net core targeting framework 4.6.1 from vs2015 to vs2017 - One or more compilation references are missing

I have upgraded my asp.net core,using project.json and targeting .net framework 4.6.1 on visual studio 2015 to visual studio 2017.
I have multiple projects in the solution where the main application is referencing them by project reference(all of them target net461).
When running the application I get
One or more compilation references are missing. Possible causes
include a missing 'preserveCompilationContext' property under
'buildOptions' in the application's project.json.
screenshot:
I have tried adding the true
to all of the reference projects without luck.
Can anyone help? Thank you.
Look in your Login.cshtml file and ensure you give the fully qualified name to the model to find your LoginViewModel and inject your SignInManager. Something like this:
#model company.Web.Models.AccountViewModels.LoginViewModel
#inject Microsoft.AspNetCore.Identity.SignInManager SignInManager
That should allow the view to serve the page correctly.

Unable to add reference to certain assemblies in VS2015 MVC project

I am relatively new to MVC, so maybe I am missing something. I am using VS 2015 Community Edition, C# 2015 & .NET Framework 4.5.2.
I have an MVC solution with 2 projects: TLM and TLM.Tests. All the .cs files in both projects are happy with the following line of code:
using System.Data;
In fact, one of the .cshtml files has this line:
#using System.Data;
Now I add a 3rd project to the solution, a Class Library called TLM.Helpers, to hold commonly used code. (In ASP.NET web forms, it would have just gone in a .cs file in the App_Code folder.) However, I cannot add a using statement for System.Data to any of the .cs files in this project. In fact, I cannot even add a reference to that DLL in this project, although I see that there is such a reference in the other 2 projects.
That new project does have successful references to System, System.Collections.Generic, and System.Linq.
Other posts for similar issues suggest verifying that the project is being built for the proper Framework version. The Property page for this project does not even offer the choice of Target Framework. It does have dropdowns for "Solution DNX SDK version", which refers to "Version 1.0.0-beta5". I don't know what that refers to.
Any suggestions as to how I can refer to System.Data in this project?
Thanks.
Dan

ASP.NET MVC source code missing solution file

I recently inherited some source code developed by someone else who is no longer with the company. However, the solution file was missing and I'm not even sure which version of MVC it was using. I'm experienced with ASP.NET, but not well-versed in MVC so I'm unsure how to go about rebuilding the solution the proper way. Looking for any tips/guidance on how to go about this.
Create a new, blank solution.
Open the solution in Windows Explorer.
Copy the project files into the solution folder.
Within Visual Studio, right-click the solution in Solution Explorer, and then chose the option to Add Existing Project....
Navigate to the solution folder (if necessary), and then select the .csproj (or .vbproj) file. The project will added into the solution.
Now, whether you can compile the solution/project depends on whether the version of MVC is compatible with the tooling installed in your instance of Visual Studio. If the project has NuGet dependencies, they should be restored the first time you build, depending (again) on your version of Visual Studio and tooling.
Edited:
Since you say that even the project file is missing, you can, assuming there are no external dependencies, create a new MVC project and then copy/paste the files into it (or drag & drop the files from Windows Explorer). Assuming there is a Views folder, it will have it's own web.config file. That config file will have bindings for the version of MVC the project was developed with.
MVC4 and newer projects tended to default to using Razor syntax, so the views will be littered with stuff like #Model. If it's using the older WebForms syntax (like <asp:ContentPlaceholder>), it's probably MVC3 or older.
Go to web.config file in the project and look for:
assembly="System.Web.Mvc,Version=3.0.0.0 ..."
In this example is.MVC 3, look for your version

Add View dialog does not work in an MVC 5 project that references an F# project

Using Visual Studio 2013, create a new ASP.NET Web Application project using the MVC template. Verify that the Add View dialog functions by right-clicking the "Views\Home" folder and choosing "Add... View".
Now add a new F# Library project to the solution. The Add View dialog should still function correctly.
Now add a project reference from the MVC project to the F# project by right-clicking the References folder, choosing Add Reference, Then browse to Solution...Projects on the left and checking the F# library project that you just added.
At this point, if you right-click the "Views\Home" folder and choose "Add... View" you will get an error in a pop-up alert box instead of the Add View dialog:
There was an error running the selected code generator: 'Object reference not set to an instance of an object.'
Workarounds include, but are hopefully not limited to:
Remove all your references to any F# projects every time you want to add a new view.
Unload any referenced F# projects, but leave the project references in place, every time you want to add a new view.
My questions are:
Are other people seeing this behavior, or is it just me?
Does anyone know of a better work-around than removing references or unloading F# projects?
Does anyone know if Microsoft is already working on fixing this? If not should this be reported to the F# team or the Visual Studio team?
Between this issue and the fact that it is still impossible to use NuGet to add an Entity Framework 6 reference to any F# project, I'm starting to get nervous about Microsoft's level of commitment to the F# language.
Not sure if this will help you but check the version of EntityFramework in your solution. I had two projects within my solution and for whatever reason, the web project had EF 6 and the class library project was EF 6.1. Once I uninstalled EF completely from the solution and reinstalled EF 6.1 on both project, the "Add new view" action started working.
I received the same error message when adding views or controllers in a C# & MVC multi-project solution, using EF 6.1 and VS2013 with Update 3. The problem was because the nuget "packages" folder was marked as read only, because it was checked into source control. I checked the entire folder out, making it editable, and it started working fine, allowing me to scaffold straight from VS.
I also received the error message in a web.api project because I forgot to add the Entity Framework connection string to the web.config (it was using Areas and EF was looking in the Area web.config, not the web.config in the root).

Monodevelop MVC3 razor - what is the trick to get it to work?

I use monodevelop 3.0.4.7 and mono 2.11.4 on mac OS 10.8.
When I create a new solution from scratch in monodevelop I can create several types of ASP.NET mvc3 projects with razor views, but the projects get created with references to system.web.helpers and system.web.webpages that are "not available for Mono/.net 4.0 in mono 2.11.4" and won't build.
If I change my .net version to 4.5 in the project options I get the system.web.webpages reference resolved, and if I simply remove the reference to system.web.helpers I am able to build the default site. However, it is unable to make use of .cshtml views, it only looks for aspx views.
I have tried different things related to references and versions of mono, changing the viewengine to razor in global.asax.cs and even copied dll's from a windows-based asp.net mvc application, but something new breaks all the time.
It seems strange that there are project types included that don't work from scratch, so I'm guessing/hoping I'm missing something much simpler?
I was sitting with the exact same problem, on Linux though, so I decided to ask on the mono mailing list (see the answer to my question here: http://lists.ximian.com/pipermail/mono-list/2012-October/049022.html).
The short answer is: no, you're not missing anything simple.
Long version: The current version of mono is not compiling the System.Web.Helpers.dll, so you have to do some footwork your self, to get it compiled. That is described in the link above.
I guess we just have to wait a little longer before this becomes part of the mono framework :/
I happened across a solution for this issue here:
http://blog.miraclespain.com/archive/2013/Jun-24.html
Basically in xamarin studio you can add a version of nuget from the following add-in repository source:
http://mrward.github.com/monodevelop-nuget-addin-repository/4.0/main.mrep
Once nuget is installed, you can create a new mvc3 razor project, notice the missing references for system.web.helpers and system.web.pages and just remove them, then use nuget to add the microsoft aspnet web pages 2 package which solves the missing references.

Resources