Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

  1. 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".
  2. Now add a new F# Library project to the solution. The Add View dialog should still function correctly.
  3. 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.

like image 683
Joel Mueller Avatar asked Oct 27 '13 22:10

Joel Mueller


People also ask

Which of the following is a type of view in MVC?

On basis of data transfer mechanism ASP.NET MVC views are categorized as two types, Dynamic view. Strongly typed view.

Where will be the view for response is decided for a specific user request in MVC pattern?

When ASP.NET MVC attempts to resolve a view template, it will first check within the \Views[Controller] specific directory, and if it can't find the view template there it will look within the \Views\Shared directory.

How can add Cshtml file in ASP.NET MVC?

Right click the Views\HelloWorld folder and click Add, then click MVC 5 View Page with Layout (Razor). In the Specify Name for Item dialog box, enter Index, and then click OK. In the Select a Layout Page dialog, accept the default _Layout. cshtml and click OK.


1 Answers

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.

like image 179
Alok Khanna Avatar answered Sep 22 '22 14:09

Alok Khanna