You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In full .NET, anonymous types are accessible via DLR across assembly boundaries if an InternalsVisibleTo attribute is present. This behavior is not the same in CoreCLR. Instead, a RuntimeBinderException is thrown.
Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'object' does not contain a definition for 'xxxx'
Consider the following scenario:
In assembly ConsoleApp:
publicclassProgram{publicstaticvoidMain(){varlist=newList<object>();
list.AddGreeting("Hello world");dynamicitem= list[0];
Console.WriteLine(item.Greeting);// throws in CoreCLR. Prints "Hello world" in full .NET}}
@natemcmaster I would recommend avoiding using anonymous types entirely within our product codebase (in tests is fine). Anonymous types can produce many surprises.
In full .NET, anonymous types are accessible via DLR across assembly boundaries if an
InternalsVisibleTo
attribute is present. This behavior is not the same in CoreCLR. Instead, aRuntimeBinderException
is thrown.Consider the following scenario:
In assembly ConsoleApp:
In assembly GreetingLibrary:
In .NET 4.5.1, this console application will print "Hello world" but in CoreCLR this application throws an exception.
Full repro project:
test-dlr-bug-master.zip
The text was updated successfully, but these errors were encountered: