FastNBag example version 0.92/.net 4 beta 2 throws Exception


Tried to run the example in the Samples/LibraryAuthors project with VS 2010 beta 2.
The program terminates with an exception.
Any ideas ?
System.InvalidCastException was unhandled
Message=The result type 'System.Void' of the dynamic binding produced by the object with type 'Bags.FastNBag' for the binder 'Microsoft.CSharp.RuntimeBinder.CSharpSetMemberBinder' is not compatible with the result type 'System.Object' expected by the call site.
   at System.Dynamic.DynamicMetaObjectBinder.Bind(Object[] args, ReadOnlyCollection`1 parameters, LabelTarget returnLabel)
   at System.Runtime.CompilerServices.CallSiteBinder.BindCore[T](CallSite`1 site, Object[] args)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
   at Bags.Program.Main(String[] args) in C:\Users\Administrator\Desktop\DLR-0.92-Src\Codeplex-DLR-0.92\Samples\LibraryAuthors\Program.cs:line 16
   at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
   at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
   at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
   at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
Closed Apr 20, 2010 at 10:36 PM by rdawson


rdawson wrote Jan 18, 2010 at 4:24 PM

Yes, this is a bug in MetaFastNBag.BindSetMember. The target expression of the DynamicMetaObject returned by this function should have the type 'object'. And specifically, the setmember operation should return the value being set. The easy fix is to change "var target=Expression.Call(...)" to "var target = Expression.Block(Expression.Call(...),valueExpr);".

This fix should be in the next source push. Thanks for pointing out the issue.