Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
Created attachment 1581 [details]
Self contained application to demonstrate DLR RuntimeBinder exception
I'm using the DLR RuntimeBinder to set values on DLR types by the field name. Getters work fine, but setters fail via the API when running under Mono (works on Microsoft .NET). When attempting to call the binder to set a field, I get this exception (only including the first few levels of the stack trace). I've attached a code sample that recreates the issue.
Unhandled Exception: Mono.CSharp.InternalErrorException: Constant value `bar' has unexpected underlying type `object'
at Mono.CSharp.Constant.CreateConstantFromValue (Mono.CSharp.TypeSpec,object,Mono.CSharp.Location) [0x001a3] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/mcs/constant.cs:156
at Microsoft.CSharp.RuntimeBinder.DynamicContext.CreateCompilerExpression (Microsoft.CSharp.RuntimeBinder.CSharpArgumentInfo,System.Dynamic.DynamicMetaObject) [0x000df] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpBinder.cs:249
at Microsoft.CSharp.RuntimeBinder.CSharpSetMemberBinder.FallbackSetMember (System.Dynamic.DynamicMetaObject,System.Dynamic.DynamicMetaObject,System.Dynamic.DynamicMetaObject) [0x00006] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/Microsoft.CSharp/Microsoft.CSharp.RuntimeBinder/CSharpSetMemberBinder.cs:54
at System.Dynamic.DynamicObject/MetaDynamic/<BindSetMember>c__AnonStorey3B.<>m__4 (System.Dynamic.DynamicMetaObject) [0x00000] in /private/tmp/monobuild/build/BUILD/mono-2.10.8/mcs/class/dlr/Runtime/Microsoft.Scripting.Core/Actions/DynamicObject.cs:247
This is not strictly Mono bug, you should not be using Constant flag for non-literal expressions.
Fixed in master (it ignores such combination).
I fixed my code. Thanks for that. I was confused that it worked on MS .NET and failed on Mono. Thanks for fixing for future versions.