Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Html helpers no longer able to infer type arguments

Full error text:

The type arguments for method 'System.Web.Mvc.Html.DisplayExtensions.DisplayFor<TModel,TValue>(System.Web.Mvc.HtmlHelper<TModel>, System.Linq.Expressions.Expression<System.Func<TModel,TValue>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

It just recently started happening, though I don't believe I made any changes that would affect this functionality. It throws VS intellisense error, but the pages function just fine.

Html helpers that are not "For" helpers work just fine, it's only the ones that contain these expressions.

The offending markup(1 example of 100s):

 <%: Html.DisplayFor(model => model.PortfolioName) %>    

Page Directive:

<%@ Page Language="C#" Inherits="ViewPage<My.Namespace.PortfolioViewModel>" %>

View Model:

namespace My.Namespace
{
    public class PortfolioViewModel
    {
        [Required(ErrorMessage = " ")]
        [DataType(DataType.Text)]
        [DisplayName("Portfolio Name:* ")]
        public string PortfolioName { get; set; }
     }
}
like image 642
Ryan O'Neill Avatar asked Mar 21 '11 21:03

Ryan O'Neill


1 Answers

It sounds stupid, I know, but have you tried closing and reopening VS?

like image 123
ARM Avatar answered Oct 06 '22 00:10

ARM