# IronRuby 0.9.2 bug - Can't define a singleton method on a COM object instance

**URL:** <https://www.ruby-forum.com/t/ironruby-0-9-2-bug-cant-define-a-singleton-method-on-a-com-object-instance/178659>\
**Category:** IronRuby\
**Created:** [November 9, 2009, 3:43am UTC](https://www.ruby-forum.com/t/ironruby-0-9-2-bug-cant-define-a-singleton-method-on-a-com-object-instance/178659 "2009-11-09T03:43:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Orion\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/65b543/32.png) [@Orion\_E](https://www.ruby-forum.com/u/Orion_E)\
**Post date:** [November 9, 2009, 3:43am UTC](https://www.ruby-forum.com/t/ironruby-0-9-2-bug-cant-define-a-singleton-method-on-a-com-object-instance/178659/1 "2009-11-09T03:43:34Z")

</div>

This code used to work under IronRuby 0.9.1 and earlier

load\_assembly “microsoft.office.word.interop”  
word = Microsoft:🏢:Interop::Word::ApplicationClass.new

metaclass = class \<\< word; self; end  
metaclass.send :define\_method, “fizz” do |\*args|  
puts “hello”  
end #BANG!

Under 0.9.2, this happens

NoMethodError: private method `singleton_method_added' called for Microsoft.Office.Interop.Word.ApplicationClass:Microsoft::Office::Interop::Word::ApplicationClass from (irb):52 from :0:in`define\_method’  
from :0:in `define_method' from :0:in`send’  
from C:/Dev/TEST/ruby/lib/ruby/1.8/irb.rb:146:in `eval_input' from C:/Dev/TEST/ruby/lib/ruby/1.8/irb.rb:70:in`start’  
from C:/Dev/TEST/ruby/lib/ruby/1.8/irb.rb:69:in `start' from :0:in`eval’  
from workspace.rb:80:in `evaluate' from context.rb:217:in`evaluate’  
from irb.rb:147:in `eval_input' from irb.rb:257:in`signal\_status’  
from irb.rb:146:in `eval_input' from ruby-lex.rb:230:in`each\_top\_level\_statement’  
from :0:in `loop' from C:/Dev/TEST/ruby/bin/iirb:13 from :0:in`catch’  
from :0:i

While the previous bug (calling super from method\_missing on a COM  
object)  
was easy to work around and isn’t that important in the scheme of  
things,  
this one is a real blocker ☹ Might have to roll back to 0.9.1 ☹

---

<div class="post-metadata">

**Author:** ![Orion\_E](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/65b543/32.png) [@Orion\_E](https://www.ruby-forum.com/u/Orion_E)\
**Post date:** [November 11, 2009, 8:57pm UTC](https://www.ruby-forum.com/t/ironruby-0-9-2-bug-cant-define-a-singleton-method-on-a-com-object-instance/178659/2 "2009-11-11T20:57:41Z")

</div>

You might be able to work this around by making singleton\_method\_added a  
public method.

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Orion E.  
Sent: Sunday, November 08, 2009 6:43 PM  
To: removed\_email\_address@domain.invalid  
Subject: [Ironruby-core] IronRuby 0.9.2 bug - Can’t define a singleton  
method on a COM object instance

This code used to work under IronRuby 0.9.1 and earlier

load\_assembly “microsoft.office.word.interop”  
word = Microsoft:🏢:Interop::Word::ApplicationClass.new

metaclass = class \<\< word; self; end  
metaclass.send :define\_method, “fizz” do |\*args|  
puts “hello”  
end #BANG!

Under 0.9.2, this happens

NoMethodError: private method `singleton_method_added' called for Microsoft.Office.Interop.Word.ApplicationClass:Microsoft::Office::Interop::Word::ApplicationClass from (irb):52 from :0:in `define\_method’  
from :0:in `define_method' from :0:in `send’  
from C:/Dev/TEST/ruby/lib/ruby/1.8/irb.rb:146:in `eval_input' from C:/Dev/TEST/ruby/lib/ruby/1.8/irb.rb:70:in `start’  
from C:/Dev/TEST/ruby/lib/ruby/1.8/irb.rb:69:in `start' from :0:in `eval’  
from workspace.rb:80:in `evaluate' from context.rb:217:in `evaluate’  
from irb.rb:147:in `eval_input' from irb.rb:257:in `signal\_status’  
from irb.rb:146:in `eval_input' from ruby-lex.rb:230:in `each\_top\_level\_statement’  
from :0:in `loop' from C:/Dev/TEST/ruby/bin/iirb:13 from :0:in `catch’  
from :0:i

While the previous bug (calling super from method\_missing on a COM  
object) was easy to work around and isn’t that important in the scheme  
of things, this one is a real blocker ☹ Might have to roll back to  
0.9.1 ☹
