[IronPython] MissingMemberException but it definitely exists
Michael Foord
fuzzyman at voidspace.org.uk
Tue Sep 8 20:17:10 CEST 2009
Jimmy Schementi wrote:
> Michael, under what situation does SL call your event handlers
> repeatidly? I'd be interested to know if even c# event handlers do the
> same thing in your situation.
>
>
Hey Jimmy. I don't know whether a minimal repro will be possible, or
whether it was something specific to my situation.
I have four comboboxes setup as two pairs (as you can see in the UI for
Try Python). Changing a selection in any of the two pairs will set the
selection to the corresponding entry in the paired combobox. Obviously
to avoid the programmatic selection change triggering *another* event I
unhook the handlers around it - which seemed to make no difference when
the event handlers were instance methods.
Approximation of the code for just two comboboxes:
class ComboHandler(object):
def __init__(class, combo1, combo2, combo3, combo4):
self.combo1 = combo1
self.combo2 = combo2
combo1.SelectedIndex = combo2.SelectedIndex = 0
self.hook_events()
def hook_events(self):
self.combo1.SelectionChanged += self.change1
self.combo2.SelectionChanged += self.change2
def unhook_events(self):
self.combo1.SelectionChanged -= self.change1
self.combo2.SelectionChanged -= self.change2
def change1(self, sender, event):
self.unhook_events()
self.combo2.SelectedIndex = self.combo1.SelectedIndex
self.hook_events()
def change2(self, sender, event):
self.unhook_events()
self.combo1.SelectedIndex = self.combo2.SelectedIndex
self.hook_events()
The code works when I turned it back into functions instead of instance
methods - but would call the handlers hundreds of times when left as
instance methods. I even tried storing a *single* reference to each of
the methods and hooking and unhooking the same objects rather than doing
a lookup each time. To no avail.
Given how much time I burned on it I was happy to end up with something
that worked...
All the best,
Michael
> ~Jimmy
>
> On Sep 7, 2009, at 3:11 PM, "Michael Foord"
> <fuzzyman at voidspace.org.uk> wrote:
>
>
>> Bob Uva wrote:
>>
>>> Michael,
>>>
>>> Saw your tweets about the Silverlight woes. Hope to avoid those
>>> problems when I follow in your footsteps soon. I'm going to a
>>> Silverlight one-day event in Redmond next week and would like to try
>>> some IronPython - Silverlight stuff before I get there.
>>>
>>>
>> Generally developing for Silverlight with IronPython is great fun -
>> but this was a real pain point. :-)
>>
>> Anyway, I've made real progress with Try Python.
>>
>> http://www.trypython.org/
>>
>> Michael
>>
>>
>>> Bob
>>>
>>> On Mon, Sep 7, 2009 at 3:05 PM, Michael Foord<fuzzyman at voidspace.org.uk
>>>
>>>> wrote:
>>>>
>>>> Bob Uva wrote:
>>>>
>>>>
>>>>> I was able to get it working by, piece by piece, recreating the
>>>>> class
>>>>> in a different file. When I was done I had what looked like exactly
>>>>> the same source but worked in one file, not the other. Couldn't get
>>>>> the original to ever work, so I just went with the new one. Pretty
>>>>> frustrating.
>>>>>
>>>>>
>>>>>
>>>> Odd. Not a problem I've ever had - but I've had my own
>>>> frustrations with
>>>> IronPython and Silverlight in the last couple of days (Silverlight
>>>> calling
>>>> my event handlers about a thousand times and even with the events
>>>> unhooked -
>>>> switching from instance methods to functions worked but screwed up
>>>> my app
>>>> architecture).
>>>>
>>>> Michael
>>>>
>>>>
>>>>
>>>>> Bob
>>>>>
>>>>> On Mon, Sep 7, 2009 at 2:30 PM, Michael Foord<fuzzyman at voidspace.org.uk
>>>>>
>>>>> wrote:
>>>>>
>>>>>
>>>>>
>>>>>> Bob Uva wrote:
>>>>>>
>>>>>>
>>>>>>
>>>>>>> I just started using IronPython and am using SharpDevelop as an
>>>>>>> IDE.
>>>>>>> I'm creating a REST web service, and have a class that has a
>>>>>>> function
>>>>>>> named 'run' in it. When I create an instance of the class and
>>>>>>> then try
>>>>>>> calling its run function I get a MissingMemberException saying
>>>>>>> that
>>>>>>> the class has no attribute 'run'. This exception is thrown from
>>>>>>> Microsoft.Scripting.Actions.MatchCaller.Call2. Shown below is
>>>>>>> the call
>>>>>>> stack shown in the exception dialog from the IDE. I've even
>>>>>>> reduced
>>>>>>> the run function to just calling pass and that doesn't work.
>>>>>>> Any ideas
>>>>>>> where to look to debug this further?
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> Can you reproduce a minimal example - without seeing any code it
>>>>>> is
>>>>>> impossible to have any idea. The first suspect I'm afraid is
>>>>>> that the
>>>>>> object
>>>>>> isn't what you think it is and doesn't have a run member.
>>>>>>
>>>>>> Michael
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>>> Thanks,
>>>>>>> Bob
>>>>>>>
>>>>>>> System.MissingMemberException: 'AddressFilesService' object has
>>>>>>> no
>>>>>>> attribute 'run'
>>>>>>> at Microsoft.Scripting.Actions.MatchCaller.Call2
>>>>>>> at
>>>>>>>
>>>>>>> Microsoft.Scripting.Actions.CallSite<
>>>>>>> Microsoft.Func<
>>>>>>> Microsoft.Scripting.Actions.CallSite,
>>>>>>> System.Object,
>>>>>>> Microsoft.Scripting.Runtime.CodeContext,
>>>>>>> System.Object>>.UpdateAndExecute
>>>>>>> at Microsoft.Scripting.Actions.UpdateDelegates.Update2
>>>>>>> at DLRCachedCode.<lambda$9>$51
>>>>>>> at Microsoft.Scripting.Actions.MatchCaller.Call1
>>>>>>> at
>>>>>>>
>>>>>>> Microsoft.Scripting.Actions.CallSite<
>>>>>>> Microsoft.Func<
>>>>>>> Microsoft.Scripting.Actions.CallSite,
>>>>>>> System.Object,System.Object>>.UpdateAndExecute
>>>>>>> at Microsoft.Scripting.Actions.UpdateDelegates.Update1
>>>>>>> at System.Threading.ThreadHelper.ThreadStart_Context
>>>>>>> at System.Threading.ExecutionContext.Run
>>>>>>> at System.Threading.ThreadHelper.ThreadStart
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>> --
>>>>>> http://www.ironpythoninaction.com/
>>>>>> http://www.voidspace.org.uk/blog
>>>>>>
>>>>>>
>>>>>> _______________________________________________
>>>>>> Users mailing list
>>>>>> Users at lists.ironpython.com
>>>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>> --
>>>> http://www.ironpythoninaction.com/
>>>> http://www.voidspace.org.uk/blog
>>>>
>>>>
>>>> _______________________________________________
>>>> Users mailing list
>>>> Users at lists.ironpython.com
>>>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>>>
>>>>
>>>>
>>>
>>>
>>>
>> --
>> http://www.ironpythoninaction.com/
>> http://www.voidspace.org.uk/blog
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.ironpython.com
>> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>>
>>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog
More information about the Ironpython-users
mailing list