<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<title>Re: [IronPython] Silverlight: Cannot cast from
'System.Nullable`1[System.Boolean]' to 'System.Boolean'</title>
<style>
<!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Gulim;
        panose-1:2 11 6 0 0 1 1 1 1 1;}
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"\@Gulim";
        panose-1:2 11 6 0 0 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Gulim","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=EN-US link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Looks like I missed it somehow – I’ve filed as bug #16831 (<a
href="http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16831">http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16831</a>).
We definitely should fix it, generally the code should work the
same the 1<sup>st</sup> time through and the 2<sup>nd</sup> time through </span><span
style='font-size:11.0pt;font-family:Wingdings;color:#1F497D'>J</span><span
style='font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D'>.<o:p></o:p></span></p>
<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p> </o:p></span></p>
<div>
<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>
<p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>From:</span></b><span
style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> Jimmy Schementi <br>
<b>Sent:</b> Wednesday, May 28, 2008 11:44 AM<br>
<b>To:</b> Discussion of IronPython; Dino Viehland<br>
<b>Subject:</b> Re: [IronPython] Silverlight: Cannot cast from
'System.Nullable`1[System.Boolean]' to 'System.Boolean'<o:p></o:p></span></p>
</div>
</div>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:11.0pt;
font-family:"Calibri","sans-serif"'>Yay for finding a IronPython bug =)
Does it work if you do IsChecked = None as well? Dino, do you know about
this?<br>
<br>
~js<br>
<br>
On 5/17/08 11:46 AM, "Michael Foord" <<a
href="fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>> wrote:</span><o:p></o:p></p>
<p class=MsoNormal style='margin-bottom:12.0pt'><span style='font-size:11.0pt;
font-family:"Calibri","sans-serif"'>This is cool. I have a checkbox in my
silverlight UI.<br>
<br>
I have a code path that does:<br>
<br>
if self.remember_me.IsChecked:<br>
PutStored(username, password)<br>
<br>
The *second* time through this code path it blows up with the exception<br>
below. I can fix it by changing the test to:<br>
<br>
if self.remember_me.IsChecked == True:<br>
PutStored(username, password)<br>
<br>
Which works fine, but I thought you might be interested. :-)<br>
<br>
Full traceback below...<br>
<br>
ArgumentException: Cannot cast from 'System.Nullable`1[System.Boolean]'<br>
to 'System.Boolean'<br>
ArgumentException<br>
at Microsoft.Scripting.Ast.LambdaCompiler.EmitCast(Type from, Type to)<br>
at Microsoft.Scripting.Ast.LambdaCompiler.Emit(UnaryExpression node)<br>
at Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node)<br>
at Microsoft.Scripting.Ast.LambdaCompiler.Emit(BinaryExpression node)<br>
at Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node)<br>
at Microsoft.Scripting.Ast.LambdaCompiler.EmitReturn(Expression expr)<br>
at Microsoft.Scripting.Ast.LambdaCompiler.Emit(ReturnStatement node)<br>
at Microsoft.Scripting.Ast.LambdaCompiler.EmitExpression(Expression node)<br>
at Microsoft.Scripting.Actions.StandardRule`1.Emit(LambdaCompiler cg,<br>
Label ifFalse)<br>
at Microsoft.Scripting.Actions.SmallRuleSet`1.MakeTarget(CodeContext<br>
context)<br>
at Microsoft.Scripting.Actions.RuleSet`1.GetOrMakeTarget(CodeContext<br>
context)<br>
at<br>
Microsoft.Scripting.Actions.DynamicSiteHelpers.UpdateSite[T](CodeContext<br>
callerContext, Object site, T& target, RuleSet`1& rules, StandardRule`1<br>
rule)<br>
at<br>
Microsoft.Scripting.Actions.RuleTree`1.GetRuleMaybeExecute(CodeContext<br>
callerContext, Object[] args, Boolean execute, Object site, T& target,<br>
RuleSet`1& rules, Object& result)<br>
at<br>
Microsoft.Scripting.Actions.RuleTree`1.ExecuteRuleAndUpdateSite(CodeContext<br>
callerContext, Object[] args, Object site, T& target, RuleSet`1& rules,<br>
Object& result)<br>
at<br>
Microsoft.Scripting.Actions.RuleCache.ActionRuleCache.ExecuteRuleAndUpdateSite[T](CodeContext<br>
context, Object[] args, Object site, T& target, RuleSet`1& rules,<br>
Object& result)<br>
at<br>
Microsoft.Scripting.Actions.RuleCache.ExecuteRuleAndUpdateSite[T](CodeContext<br>
callerContext, DynamicAction action, Object[] args, Object site, T&<br>
target, RuleSet`1& rules, Object& result)<br>
at<br>
Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext<br>
callerContext, DynamicAction action, Object[] args, Object site, T&<br>
target, RuleSet`1& rules)<br>
at<br>
Microsoft.Scripting.Actions.DynamicSite`2.UpdateBindingAndInvoke(CodeContext<br>
context, T0 arg0)<br>
at<br>
Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke1(DynamicSite`2<br>
site, CodeContext context, T0 arg0)<br>
at Microsoft.Scripting.Actions.DynamicSite`2.Invoke(CodeContext context,<br>
T0 arg0)<br>
at _stub_##224(Closure , DynamicSite`2 , CodeContext , Object )<br>
at Microsoft.Scripting.Actions.DynamicSite`2.Invoke(CodeContext context,<br>
T0 arg0)<br>
at S$3.onLogin$18(Closure , Object self, Object sender, Object event)<br>
at Microsoft.Scripting.Utils.InvokeHelper`5.Invoke(Object arg0, Object<br>
arg1, Object arg2, Object arg3)<br>
at Microsoft.Scripting.Utils.ReflectedCaller.InvokeInstance(Object<br>
instance, Object[] args)<br>
at Microsoft.Scripting.Ast.Interpreter.InvokeMethod(MethodInfo method,<br>
Object instance, Object[] parameters)<br>
at<br>
Microsoft.Scripting.Ast.Interpreter.InterpretMethodCallExpression(CodeContext<br>
context, Expression expr)<br>
at Microsoft.Scripting.Ast.Interpreter.Interpret(CodeContext context,<br>
Expression expr)<br>
at<br>
Microsoft.Scripting.Ast.Interpreter.InterpretReturnStatement(CodeContext<br>
context, Expression expr)<br>
at Microsoft.Scripting.Ast.Interpreter.Interpret(CodeContext context,<br>
Expression expr)<br>
at Microsoft.Scripting.Ast.Interpreter.Execute(CodeContext context,<br>
Expression expression)<br>
at Microsoft.Scripting.Actions.StandardRule`1.ExecuteTarget(Object site,<br>
CodeContext context, Object[] args)<br>
at<br>
Microsoft.Scripting.Actions.RuleTree`1.GetRuleMaybeExecute(CodeContext<br>
callerContext, Object[] args, Boolean execute, Object site, T& target,<br>
RuleSet`1& rules, Object& result)<br>
at<br>
Microsoft.Scripting.Actions.RuleTree`1.ExecuteRuleAndUpdateSite(CodeContext<br>
callerContext, Object[] args, Object site, T& target, RuleSet`1& rules,<br>
Object& result)<br>
at<br>
Microsoft.Scripting.Actions.RuleCache.ActionRuleCache.ExecuteRuleAndUpdateSite[T](CodeContext<br>
context, Object[] args, Object site, T& target, RuleSet`1& rules,<br>
Object& result)<br>
at<br>
Microsoft.Scripting.Actions.RuleCache.ExecuteRuleAndUpdateSite[T](CodeContext<br>
callerContext, DynamicAction action, Object[] args, Object site, T&<br>
target, RuleSet`1& rules, Object& result)<br>
at<br>
Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext<br>
callerContext, DynamicAction action, Object[] args, Object site, T&<br>
target, RuleSet`1& rules)<br>
at<br>
Microsoft.Scripting.Actions.DynamicSite`5.UpdateBindingAndInvoke(CodeContext<br>
context, T0 arg0, T1 arg1, T2 arg2, T3 arg3)<br>
at<br>
Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke4(DynamicSite`5<br>
site, CodeContext context, T0 arg0, T1 arg1, T2 arg2, T3 arg3)<br>
at Microsoft.Scripting.Actions.DynamicSite`5.Invoke(CodeContext context,<br>
T0 arg0, T1 arg1, T2 arg2, T3 arg3)<br>
at _stub_##217(Closure , DynamicSite`4 , CodeContext , Object , Object ,<br>
Object )<br>
at Microsoft.Scripting.Actions.DynamicSite`4.Invoke(CodeContext context,<br>
T0 arg0, T1 arg1, T2 arg2)<br>
at System.Void(Object, RoutedEventArgs), using PythonBinder##183(Closure<br>
, Object , RoutedEventArgs )<br>
at System.Windows.Controls.Primitives.ButtonBase.OnClick()<br>
at<br>
System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs<br>
e)<br>
at<br>
System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(Object<br>
sender, MouseButtonEventArgs e)<br>
at System.Windows.CoreInvokeHandler.InvokeEventHandler(Int32 typeIndex,<br>
Delegate handlerDelegate, Object sender, Object args)<br>
at MS.Internal.JoltHelper.FireEvent(IntPtr unmanagedObj, IntPtr<br>
unmanagedObjArgs, Int32 argsTypeIndex, String eventName)<br>
? Hide<br>
Debugging Output<br>
<br>
<br>
Michael Foord<br>
<a href="http://www.ironpythoninaction.com/">http://www.ironpythoninaction.com/</a><br>
<br>
<br>
_______________________________________________<br>
Users mailing list<br>
<a href="Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a></span><o:p></o:p></p>
</div>
</body>
</html>