Bug 23789 - Microsoft.CSharp.RuntimeBinder.RuntimeBinderException with List<>
Summary: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException with List<>
Status: RESOLVED INVALID
Alias: None
Product: Class Libraries
Classification: Mono
Component: System.Web ()
Version: 3.8.0
Hardware: PC Linux
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-10-13 15:53 UTC by Jan
Modified: 2014-10-15 15:07 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on GitHub or Developer Community with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED INVALID

Description Jan 2014-10-13 15:53:30 UTC
I have created a MVC application with this home controller:

    public class HomeController : Controller
    {
        public ActionResult Index()
        {
			User user1 = new User ();
			user1.Name = "Name 1";
			user1.Address = "City 1";

			User user2 = new User ();
			user2.Name = "Name 2";
			user2.Address = "City 2";

 			List<User> l = new List<User> ();
			l.Add (user1);
			l.Add (user2);

			return View(l);
        }
    }

    public class User
    {
        [Required]
        [MinLength(4)]
        public string Name { get; set; }
        public string Address { get; set; }
        public int Age { get; set; }
    }

This will result the following exception:
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException
`System.Collections.Generic.List<test4.Web.Models.User>' does not contain a definition for `Address'
Comment 1 Zoltan Varga 2014-10-15 12:55:54 UTC
-> Sys.Web
Comment 2 Jan 2014-10-15 15:07:55 UTC
Sorry, it was my fault. There was an access on address-field in the _Layout.cshtml.