I am getting an odd error from an MVC3 webforms view that has stumped me.
Setup:
I have two interfaces defined:
public interface IDbObject {
int Id { get; set; }
string Name { get; set; }
}
public interface IAutomobile : IDbObject {
string VIN { get; set; }
}
public class Automobile : IAutomobile {
public int Id { get; set; }
public string Name { get; set; }
public string VIN { get; set; }
}
My view is a strongly-typed view: System.Web.Mvc.ViewPage<IAutomobile> and my controller
When I attempt to use a EditorFor on the Name property
<%= Html.EditorFor(a => a.Name) %>
I get an exception: System.ArgumentException: The property IAutomobile.Name could not be found.
However, if I comment out this statement, my EditorFor on the VIN continues to function properly:
<%= Html.EditorFor(a => a.VIN) %>
Is there something I’m missing?
Solution found:
I re-implemented the ‘Name’ property on the IAutomobile interface:
I made no changes to my concrete class, and the EditorFor method was able to work with the Name property.