Bug 4105 - DLR RuntimeBinder exception creating constant from value
Summary: DLR RuntimeBinder exception creating constant from value
Alias: None
Product: Class Libraries
Classification: Mono
Component: System ()
Version: 2.10.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2012-03-26 22:42 UTC by curylod
Modified: 2012-03-28 22:54 UTC (History)
3 users (show)

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

Self contained application to demonstrate DLR RuntimeBinder exception (2.61 KB, application/octet-stream)
2012-03-26 22:42 UTC, curylod

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:

Description curylod 2012-03-26 22:42:38 UTC
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
Comment 1 Marek Safar 2012-03-27 06:38:27 UTC
This is not strictly Mono bug, you should not be using Constant flag for non-literal expressions.

Fixed in master (it ignores such combination).
Comment 2 curylod 2012-03-28 22:54:09 UTC
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.