I get an error message:
"object" does not contain a definition for "Title"
all code is also on github
I have ConsoleApplication1 that looks like
namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Movie m = new Movie(); var o = new { Title = "Ghostbusters", Rating = "PG" }; Console.WriteLine(m.PrintMovie(o)); } } }
and movie.cs
public class Movie : DynamicObject { public string PrintMovie(dynamic o) { return string.Format("Title={0} Rating={1}", o.Title, o.Rating); } }
it works fine in the SAME project, but if I add ConsoleApplication2 with reference to ConsoleApplication1 and add the exact code
namespace ConsoleApplication2 { class Program { static void Main(string[] args) { Movie m = new Movie(); var o = new { Title = "Ghostbusters", Rating = "PG" }; Console.WriteLine(m.PrintMovie(o)); } } }
I get an error message:
'object' does not contain a definition for 'Title' **
although it is in a dynamic object.
- o.Title 'o.Title' threw an exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' dynamic {Microsoft.CSharp.RuntimeBinder.RuntimeBinderException}
Here is a screenshot: 
I am doing something like this and trying to call a movie function from a test project.
eiu165 Feb 23 2018-12-12T00: 00Z
source share