[IronPython] Silverlight: Cannot cast from 'System.Nullable`1[System.Boolean]' to 'System.Boolean'

Michael Foord fuzzyman at voidspace.org.uk
Sat May 17 20:46:33 CEST 2008


This is cool. I have a checkbox in my silverlight UI.

I have a code path that does:

if self.remember_me.IsChecked:
PutStored(username, password)

The *second* time through this code path it blows up with the exception 
below. I can fix it by changing the test to:

if self.remember_me.IsChecked == True:
PutStored(username, password)

Which works fine, but I thought you might be interested. :-)

Full traceback below...

ArgumentException: Cannot cast from 'System.Nullable`1[System.Boolean]' 
to 'System.Boolean'
ArgumentException
at Microsoft.Scripting.Ast.LambdaCompiler.EmitCast(Type from, Type to)
at Microsoft.Scripting.Ast.LambdaCompiler.Emit(UnaryExpression node)
at Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node)
at Microsoft.Scripting.Ast.LambdaCompiler.Emit(BinaryExpression node)
at Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node)
at Microsoft.Scripting.Ast.LambdaCompiler.EmitReturn(Expression expr)
at Microsoft.Scripting.Ast.LambdaCompiler.Emit(ReturnStatement node)
at Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node)
at Microsoft.Scripting.Actions.StandardRule`1.Emit(LambdaCompiler cg, 
Label ifFalse)
at Microsoft.Scripting.Actions.SmallRuleSet`1.MakeTarget(CodeContext 
context)
at Microsoft.Scripting.Actions.RuleSet`1.GetOrMakeTarget(CodeContext 
context)
at 
Microsoft.Scripting.Actions.DynamicSiteHelpers.UpdateSite[T](CodeContext 
callerContext, Object site, T& target, RuleSet`1& rules, StandardRule`1 
rule)
at 
Microsoft.Scripting.Actions.RuleTree`1.GetRuleMaybeExecute(CodeContext 
callerContext, Object[] args, Boolean execute, Object site, T& target, 
RuleSet`1& rules, Object& result)
at 
Microsoft.Scripting.Actions.RuleTree`1.ExecuteRuleAndUpdateSite(CodeContext 
callerContext, Object[] args, Object site, T& target, RuleSet`1& rules, 
Object& result)
at 
Microsoft.Scripting.Actions.RuleCache.ActionRuleCache.ExecuteRuleAndUpdateSite[T](CodeContext 
context, Object[] args, Object site, T& target, RuleSet`1& rules, 
Object& result)
at 
Microsoft.Scripting.Actions.RuleCache.ExecuteRuleAndUpdateSite[T](CodeContext 
callerContext, DynamicAction action, Object[] args, Object site, T& 
target, RuleSet`1& rules, Object& result)
at 
Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext 
callerContext, DynamicAction action, Object[] args, Object site, T& 
target, RuleSet`1& rules)
at 
Microsoft.Scripting.Actions.DynamicSite`2.UpdateBindingAndInvoke(CodeContext 
context, T0 arg0)
at 
Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke1(DynamicSite`2 
site, CodeContext context, T0 arg0)
at Microsoft.Scripting.Actions.DynamicSite`2.Invoke(CodeContext context, 
T0 arg0)
at _stub_##224(Closure , DynamicSite`2 , CodeContext , Object )
at Microsoft.Scripting.Actions.DynamicSite`2.Invoke(CodeContext context, 
T0 arg0)
at S$3.onLogin$18(Closure , Object self, Object sender, Object event)
at Microsoft.Scripting.Utils.InvokeHelper`5.Invoke(Object arg0, Object 
arg1, Object arg2, Object arg3)
at Microsoft.Scripting.Utils.ReflectedCaller.InvokeInstance(Object 
instance, Object[] args)
at Microsoft.Scripting.Ast.Interpreter.InvokeMethod(MethodInfo method, 
Object instance, Object[] parameters)
at 
Microsoft.Scripting.Ast.Interpreter.InterpretMethodCallExpression(CodeContext 
context, Expression expr)
at Microsoft.Scripting.Ast.Interpreter.Interpret(CodeContext context, 
Expression expr)
at 
Microsoft.Scripting.Ast.Interpreter.InterpretReturnStatement(CodeContext 
context, Expression expr)
at Microsoft.Scripting.Ast.Interpreter.Interpret(CodeContext context, 
Expression expr)
at Microsoft.Scripting.Ast.Interpreter.Execute(CodeContext context, 
Expression expression)
at Microsoft.Scripting.Actions.StandardRule`1.ExecuteTarget(Object site, 
CodeContext context, Object[] args)
at 
Microsoft.Scripting.Actions.RuleTree`1.GetRuleMaybeExecute(CodeContext 
callerContext, Object[] args, Boolean execute, Object site, T& target, 
RuleSet`1& rules, Object& result)
at 
Microsoft.Scripting.Actions.RuleTree`1.ExecuteRuleAndUpdateSite(CodeContext 
callerContext, Object[] args, Object site, T& target, RuleSet`1& rules, 
Object& result)
at 
Microsoft.Scripting.Actions.RuleCache.ActionRuleCache.ExecuteRuleAndUpdateSite[T](CodeContext 
context, Object[] args, Object site, T& target, RuleSet`1& rules, 
Object& result)
at 
Microsoft.Scripting.Actions.RuleCache.ExecuteRuleAndUpdateSite[T](CodeContext 
callerContext, DynamicAction action, Object[] args, Object site, T& 
target, RuleSet`1& rules, Object& result)
at 
Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext 
callerContext, DynamicAction action, Object[] args, Object site, T& 
target, RuleSet`1& rules)
at 
Microsoft.Scripting.Actions.DynamicSite`5.UpdateBindingAndInvoke(CodeContext 
context, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at 
Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke4(DynamicSite`5 
site, CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at Microsoft.Scripting.Actions.DynamicSite`5.Invoke(CodeContext context, 
T0 arg0, T1 arg1, T2 arg2, T3 arg3)
at _stub_##217(Closure , DynamicSite`4 , CodeContext , Object , Object , 
Object )
at Microsoft.Scripting.Actions.DynamicSite`4.Invoke(CodeContext context, 
T0 arg0, T1 arg1, T2 arg2)
at System.Void(Object, RoutedEventArgs), using PythonBinder##183(Closure 
, Object , RoutedEventArgs )
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at 
System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs 
e)
at 
System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(Object 
sender, MouseButtonEventArgs e)
at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex, 
Delegate handlerDelegate, Object sender, Object args)
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr 
unmanagedObjArgs, Int32 argsTypeIndex, String eventName)
⇓ Hide
Debugging Output


Michael Foord
http://www.ironpythoninaction.com/





More information about the Ironpython-users mailing list