# Having difficulties using custom C# dlls with namespaces within IronRuby code

**URL:** <https://www.ruby-forum.com/t/having-difficulties-using-custom-c-dlls-with-namespaces-within-ironruby-code/140273>\
**Category:** IronRuby\
**Created:** [June 12, 2008, 2:43pm UTC](https://www.ruby-forum.com/t/having-difficulties-using-custom-c-dlls-with-namespaces-within-ironruby-code/140273 "2008-06-12T14:43:21Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![pmouawad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@pmouawad](https://www.ruby-forum.com/u/pmouawad)\
**Post date:** [June 12, 2008, 2:43pm UTC](https://www.ruby-forum.com/t/having-difficulties-using-custom-c-dlls-with-namespaces-within-ironruby-code/140273/1 "2008-06-12T14:43:21Z")

</div>

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

---

<div class="post-metadata">

**Author:** ![pmouawad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@pmouawad](https://www.ruby-forum.com/u/pmouawad)\
**Post date:** [June 12, 2008, 3:04pm UTC](https://www.ruby-forum.com/t/having-difficulties-using-custom-c-dlls-with-namespaces-within-ironruby-code/140273/2 "2008-06-12T15:04:39Z")

</div>

For me that just works with a namespace  
what I do is I have my assemblies in a folder bin in my application but  
that  
could be what ever

I call require ‘bin/AssemblyName.dll’

In that assembly I have a namespace MyNamespace.Model

then I can do  
include MyNamespace::Model

if that namespace contains a class called Message I can now use it as  
message = Message.new  
message.content = “The body of the test message”

puts message.content

I don’t know if you know about this but Rails 2.0 has a component  
ActiveResource which should replace ActiveWebservice.  
That component allows you to use the resources (if you’re using the  
restful  
routing that is) you’ve exposed for your rest application and on the  
client  
side you can use that same active resource stuff to create proxies and  
do  
queries against that rest service in a fairly nice way.

hope this helps  
Ivan

On Fri, Jun 13, 2008 at 12:36 AM, Philippe M.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![pmouawad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@pmouawad](https://www.ruby-forum.com/u/pmouawad)\
**Post date:** [June 12, 2008, 3:03pm UTC](https://www.ruby-forum.com/t/having-difficulties-using-custom-c-dlls-with-namespaces-within-ironruby-code/140273/3 "2008-06-12T15:03:28Z")

</div>

2008/6/12 Philippe M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> - the require “mywebsvcproxy” returns true
> - if I evaluate mywebsvcproxyns I get undefined

This is the expected behavior. See:

irb\> require ‘date’  
=\> true  
irb\> date  
NameError: …  
irb\> Date  
=\> Date

As in the above Ruby session, require in Ruby does not create a local  
variable with the filename in the namespace. It simply makes classes  
defined in the file available. IronRuby follows this behavior when  
requiring DLL, so,

require ‘mydllname’  
MyDLLObject = MyDLLNamespace::MyDLLClass.new  
…

---

<div class="post-metadata">

**Author:** ![pmouawad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@pmouawad](https://www.ruby-forum.com/u/pmouawad)\
**Post date:** [June 12, 2008, 3:05pm UTC](https://www.ruby-forum.com/t/having-difficulties-using-custom-c-dlls-with-namespaces-within-ironruby-code/140273/4 "2008-06-12T15:05:14Z")

</div>

Oops, I misinterpreted. Disregard my mail.

---

<div class="post-metadata">

**Author:** ![pmouawad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@pmouawad](https://www.ruby-forum.com/u/pmouawad)\
**Post date:** [June 12, 2008, 6:32pm UTC](https://www.ruby-forum.com/t/having-difficulties-using-custom-c-dlls-with-namespaces-within-ironruby-code/140273/5 "2008-06-12T18:32:38Z")

</div>

The casing is not right.

include mywebsvcproxyns

is the same as

include(mywebsvcproxyns())

I.e. mywebsvcproxyns is a method call.

You need to start namespaces with a capital letter. BTW, that’s also  
.NET naming convention.

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Philippe  
Monnet  
Sent: Thursday, June 12, 2008 5:37 AM  
To: IronRuby  
Subject: [Ironruby-core] Having difficulties using custom C# dlls with  
namespaces within IronRuby code

Now that the Beta 2 of Silverlight provides support for WSI web  
services, I can now get an all-C# Silverlight app to call Rails (Action  
Web Service) web services.  
So I encapsulated my generated web service proxy in its own DLL so I can  
use it from Ruby, like so:

…  
require “System.ServiceModel”  
require “mywebsvcproxy” #my DLL  
…  
include System::ServiceModel  
include mywebsvcproxyns  
…  
svcproxy =  
mywebsvcproxyns::MyRoRServiceReference::MyRorWsPortClient.new()  
… etc …

However I keep getting an error as soon as I hit the include for my  
assembly namespace.  
I have tried to simplify the issue by creating a very tiny assembly with  
a C# class with 2 properties and a constructor but I get the same issue.  
I even tried that from IR with the same results:

- the require “mywebsvcproxy” returns true
- if I evaluate mywebsvcproxyns I get undefined  
The DLL is in the same location as other .rb files in my Silverlight app  
directory. I have even tried to provide an absolute path in the require  
statement but that did not make any difference.  
After putting this email on hold for another check, I found out that as  
soon as I remove the namespace inside my custom assembly everything  
works like a charm. I ended up also removing all namespace references in  
the C# generated proxy and was able to get my IronRuby Silverlight app  
to successfully invoke my Rails web service.

But coming back to the namespace issue, am I missing something basic in  
how I should be integrating with custom assemblies?  
Or is this a limitation for the time being?

Philippe

---

<div class="post-metadata">

**Author:** ![pmouawad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@pmouawad](https://www.ruby-forum.com/u/pmouawad)\
**Post date:** [June 12, 2008, 8:56pm UTC](https://www.ruby-forum.com/t/having-difficulties-using-custom-c-dlls-with-namespaces-within-ironruby-code/140273/6 "2008-06-12T20:56:15Z")

</div>

* * *

Ironruby-core mailing list  
removed\_email\_address@domain.invalid  
[http://rubyforge.org/mailman/listinfo/ironruby-core](http://rubyforge.org/mailman/listinfo/ironruby-core)

---

<div class="post-metadata">

**Author:** ![pmouawad](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/ee59a6/32.png) [@pmouawad](https://www.ruby-forum.com/u/pmouawad)\
**Post date:** [June 12, 2008, 6:35pm UTC](https://www.ruby-forum.com/t/having-difficulties-using-custom-c-dlls-with-namespaces-within-ironruby-code/140273/7 "2008-06-12T18:35:35Z")

</div>

Yeah, but we’re also going to have to think about some way to workaround  
this problem since we’re going to run into cases out there with folks  
who have compiled assemblies that don’t follow the .NET naming  
conventions (unbelievable but true! :))

Thanks,  
-John
