# IronRuby overloaded method selection?

**URL:** <https://www.ruby-forum.com/t/ironruby-overloaded-method-selection/160714>\
**Category:** IronRuby\
**Created:** [February 19, 2009, 2:32am UTC](https://www.ruby-forum.com/t/ironruby-overloaded-method-selection/160714 "2009-02-19T02:32:21Z")\
**Posts on this page:** 3\
**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:** [February 19, 2009, 2:32am UTC](https://www.ruby-forum.com/t/ironruby-overloaded-method-selection/160714/1 "2009-02-19T02:32:21Z")

</div>

I have the following C# code, which I’m trying to translate to IronRuby

var host = new ServiceHost(typeof(MyService ));  
host.AddServiceEndpoint(typeof(IWcfContract), new WSHttpBinding(), new  
Uri(“…”));

This compiles fine.

My ruby translation looks like this:

host = ServiceHost.new( MyService ) # this line works fine  
host.add\_service\_endpoint( IWcfContract, WSHttpBinding.new,  
Uri.new(“…”) )

As far as I can tell, that’s a direct translation and how it should  
work,  
but the second line always throws

wrong number or type of arguments for `add\_service\_endpoint’  
(ArgumentError)

Is it something to do with the way IronRuby resolves overloads? that  
method  
has about 8 different overloads, but I’ve tried  
passing in strings (and all the other overload combinations), and  
nothing  
helps.

Note which may be of use: The second parameter is typed to accept  
System.ServiceModel.Channels.Binding, whereas the WSHttpBinding is about  
3  
or 4 steps down (up?) the inheritance tree from that. Could that be  
confusing it?

Note 2: I’m running this particular IronRuby =\>  
[http://nbs.blob.core.windows.net/dlr/DLR.10369.release.zip](http://nbs.blob.core.windows.net/dlr/DLR.10369.release.zip)

At any rate:

1. How can I figure out which overload IronRuby is deciding to call?
2. How can I make it select the correct overload if it’s not doing so?

---

<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:** [February 19, 2009, 3:53am UTC](https://www.ruby-forum.com/t/ironruby-overloaded-method-selection/160714/2 "2009-02-19T03:53:52Z")

</div>

Could you try the latest build?  
Also try:

host.method(:add\_service\_endpoint).clr\_members.each { |m| puts  
m.to\_string }

What does it print?

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: Wednesday, February 18, 2009 5:26 PM  
To: removed\_email\_address@domain.invalid  
Subject: [Ironruby-core] IronRuby overloaded method selection?

I have the following C# code, which I’m trying to translate to IronRuby

var host = new ServiceHost(typeof(MyService ));  
host.AddServiceEndpoint(typeof(IWcfContract), new WSHttpBinding(), new  
Uri(“…”));

This compiles fine.

My ruby translation looks like this:

host = ServiceHost.new( MyService ) # this line works fine  
host.add\_service\_endpoint( IWcfContract, WSHttpBinding.new,  
Uri.new(“…”) )

As far as I can tell, that’s a direct translation and how it should  
work, but the second line always throws

wrong number or type of arguments for `add\_service\_endpoint’  
(ArgumentError)

Is it something to do with the way IronRuby resolves overloads? that  
method has about 8 different overloads, but I’ve tried  
passing in strings (and all the other overload combinations), and  
nothing helps.

Note which may be of use: The second parameter is typed to accept  
System.ServiceModel.Channels.Binding, whereas the WSHttpBinding is about  
3 or 4 steps down (up?) the inheritance tree from that. Could that be  
confusing it?

Note 2: I’m running this particular IronRuby =\>  
[http://nbs.blob.core.windows.net/dlr/DLR.10369.release.zip](http://nbs.blob.core.windows.net/dlr/DLR.10369.release.zip)

At any rate:

1. How can I figure out which overload IronRuby is deciding to call?
2. How can I make it select the correct overload if it’s not doing so?

---

<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:** [February 22, 2009, 9:16pm UTC](https://www.ruby-forum.com/t/ironruby-overloaded-method-selection/160714/3 "2009-02-22T21:16:12Z")

</div>

I’m now running 10606 from the nightly builds, and it seems to be  
somewhat  
fixed, but still not functioning. The error message now reads:

host.add\_service\_endpoint( IWcfContract, WSHttpBinding.new,  
Uri.new("…") )  
=\> :0: can’t convert Module into ClrString (TypeError)

Running the code you suggested gives this:

> > > host.method(:add\_service\_endpoint).clr\_members.each { |m| puts  
> > > m.to\_string }  
> > > System.ServiceModel.Description.ServiceEndpoint  
> > > AddServiceEndpoint(System.String, System.ServiceModel.Channels.Binding,  
> > > System.String)  
> > > System.ServiceModel.Description.ServiceEndpoint  
> > > AddServiceEndpoint(System.String, System.ServiceModel.Channels.Binding,  
> > > System.String, System.Uri)  
> > > System.ServiceModel.Description.ServiceEndpoint  
> > > AddServiceEndpoint(System.String, System.ServiceModel.Channels.Binding,  
> > > System.Uri)  
> > > System.ServiceModel.Description.ServiceEndpoint  
> > > AddServiceEndpoint(System.String, System.ServiceModel.Channels.Binding,  
> > > System.Uri, System.Uri)  
> > > System.ServiceModel.Description.ServiceEndpoint  
> > > AddServiceEndpoint(System.Type, System.ServiceModel.Channels.Binding,  
> > > System.String)  
> > > System.ServiceModel.Description.ServiceEndpoint  
> > > AddServiceEndpoint(System.Type, System.ServiceModel.Channels.Binding,  
> > > System.String, System.Uri)  
> > > System.ServiceModel.Description.ServiceEndpoint  
> > > AddServiceEndpoint(System.Type, System.ServiceModel.Channels.Binding,  
> > > System.Uri)  
> > > System.ServiceModel.Description.ServiceEndpoint  
> > > AddServiceEndpoint(System.Type, System.ServiceModel.Channels.Binding,  
> > > System.Uri, System.Uri)

It looks like IronRuby is having to choose between (String, Binding,  
Uri)  
and (Type, Binding, Uri), and is selecting the former (when I want it to  
select the latter).

I’ve tried doing this

host.add\_service\_endpoint( IWcfContract.to\_clr\_type, WSHttpBinding.new,  
Uri.new("…") )

but the error message is still the same (can’t convert module to  
ClrString).

to\_clr\_type returns a System.RuntimeType - does this inherit from  
System.Type or is it a different thing entirely? - my knowledge of the  
CLR  
in this area is somewhat weak ☹

Thanks a lot
