[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

.NET dll in Ruby

Patrick Spence

8/25/2006 2:02:00 PM

I have a "COM enabled" C# .NET .dll. I need to instanciate it in some
Ruby code. Has anyone done something like this? If so, how? It doesn't
seem to be as straight forward as a VB6 COM .dll.

--
Posted via http://www.ruby-....

9 Answers

brabuhr

8/25/2006 2:29:00 PM

0

On 8/25/06, Patrick Spence <patrick@pkspence.com> wrote:
> I have a "COM enabled" C# .NET .dll. I need to instanciate it in some
> Ruby code. Has anyone done something like this? If so, how? It doesn't
> seem to be as straight forward as a VB6 COM .dll.

Have you looked at RubyCLR (http://www.r...)?

William Crawford

8/25/2006 2:37:00 PM

0

unknown wrote:
> On 8/25/06, Patrick Spence <patrick@pkspence.com> wrote:
>> I have a "COM enabled" C# .NET .dll. I need to instanciate it in some
>> Ruby code. Has anyone done something like this? If so, how? It doesn't
>> seem to be as straight forward as a VB6 COM .dll.
>
> Have you looked at RubyCLR (http://www.r...)?

As someone who has programmed in C#, this appeals to me. Too bad
there's almost no information on the project there.

--
Posted via http://www.ruby-....

Sam Smoot

8/25/2006 2:45:00 PM

0


Patrick Spence wrote:
> I have a "COM enabled" C# .NET .dll. I need to instanciate it in some
> Ruby code. Has anyone done something like this? If so, how? It doesn't
> seem to be as straight forward as a VB6 COM .dll.
>
> --
> Posted via http://www.ruby-....

I've used WIN32OLE with .NET COM wrappers just fine...

regasm /tlb /codebase mywrapper.dll

obj = WIN32OLE.new 'MyWrapper.AwesomeObject'
obj.DoSomethingReallyCool()

For a RubyClr example:

require 'rubyclr'
reference 'System'

include System

sb = Text::StringBuilder.new
sb.append 'This '
sb.append 'is '
sb.append 'how '
sb.append 'it\'s '
sb.append 'done'

"This is how it's done" == sb.to_string

brabuhr

8/25/2006 3:53:00 PM

0

On 8/25/06, Patrick Spence <patrick@pkspence.com> wrote:
> >> I have a "COM enabled" C# .NET .dll. I need to instanciate it in some
> >> Ruby code. Has anyone done something like this? If so, how? It doesn't
> >> seem to be as straight forward as a VB6 COM .dll.
> >
> > Have you looked at RubyCLR (http://www.r...)?

On 8/25/06, William Crawford <wccrawford@gmail.com> wrote:
> As someone who has programmed in C#, this appeals to me. Too bad
> there's almost no information on the project there.

Also some information at:
http://rubyforge.org/project...
http://www.iunknown.com/articles/t...

William Crawford

8/25/2006 4:01:00 PM

0

unknown wrote:
> On 8/25/06, Patrick Spence <patrick@pkspence.com> wrote:
>> >> I have a "COM enabled" C# .NET .dll. I need to instanciate it in some
>> >> Ruby code. Has anyone done something like this? If so, how? It doesn't
>> >> seem to be as straight forward as a VB6 COM .dll.
>> >
>> > Have you looked at RubyCLR (http://www.r...)?
>
> On 8/25/06, William Crawford <wccrawford@gmail.com> wrote:
>> As someone who has programmed in C#, this appeals to me. Too bad
>> there's almost no information on the project there.
>
> Also some information at:
> http://rubyforge.org/project...
> http://www.iunknown.com/articles/t...

The second one at least has an example, but the first one... There's 1
forum post and 1 bug in the tracker. That's not really my idea of
'information' on a project as big as making a new language work on the
NET CLR.

Even the most basic information is missing, like: What version of Ruby
does this equate to? What is and isn't implemented?

I assume it won't run ruby gems... But I don't know that, because
there's no information.

--
Posted via http://www.ruby-....

Patrick Spence

8/25/2006 4:05:00 PM

0

Sam Smoot wrote:
> I've used WIN32OLE with .NET COM wrappers just fine...
>
> regasm /tlb /codebase mywrapper.dll
>
> obj = WIN32OLE.new 'MyWrapper.AwesomeObject'
> obj.DoSomethingReallyCool()
>

Ok, I've got that working, well, sort of... The class has several public
properties and one public method. The only methods that show up via any
of the "ole_*" methods, are the IDispatch methods; QueryInterface,
AddRef, Release, etc.. Interestingly enough, however, I am able to
assign a value to one of the public properties w/o Ruby choking. Is
there some reason they don't show up?



--
Posted via http://www.ruby-....

brabuhr

8/25/2006 5:41:00 PM

0

> > Also some information at:
> > http://rubyforge.org/project...
> > http://www.iunknown.com/articles/t...
(looks like the tag isn't very useful, better to search for RubyCLR)

> The second one at least has an example, but the first one... There's 1
> forum post and 1 bug in the tracker. That's not really my idea of
> 'information' on a project as big as making a new language work on the
> .NET CLR.

Consider 'some' as my propensity for understatement :-) It's not really
running Ruby on the CLR (like, for example Ruby.NET); it's an extension
module for Ruby 1.8 Win32 (I don't know if anyone has tested with
anything other than the One-Click Installer) to work with .NET objects
from Ruby. (I think that one of his prime motivations in writing this was
to use the .NET user-interface features he wanted while the logic driving
the interface stayed in elegant Ruby.)

http://rubyforge.org/plugins/scmsvn/viewcvs.php/trunk/README.TXT?root=rubyclr&v...
http://rubyforge.org/plugins/scmsvn/viewcvs.php/trunk/Samples/?ro...

Something like:

require 'rubyclr'
RubyClr::reference 'System'
System::Console.WriteLine("Hello")

I've used it from Rails to work with model data from a proprietary data store.

David Vallner

8/25/2006 8:56:00 PM

0

Patrick Spence wrote:
> Has anyone done something like this? If so, how? It doesn't
> seem to be as straight forward as a VB6 COM .dll.

Amusingly enough:

irb(main):001:0> require 'win32ole'
=> true
irb(main):002:0> lst = WIN32OLE.new("System.Collections.ArrayList")
=> #<WIN32OLE:0x5f41780>
irb(main):003:0> lst.add('foo')
=> 0
irb(main):004:0> lst.add('bar')
=> 1
irb(main):005:0> lst.add('baz')
=> 2
irb(main):006:0> lst.Count
=> 3
irb(main):007:0> lst.Item(0)
=> "foo"
irb(main):008:0> lst.Item(1)
=> "bar"
irb(main):009:0> lst.Item(2)
=> "baz"

sans rubyclr. Maybe there's a problem with your DLL or its
COM-enabledness? Of course I just might have stumbled on a
System.Collections.ArrayList that is pre-.NET - I'm not too COM-savvy.

David Vallner

John Lam

8/26/2006 1:01:00 AM

0

I would suggest that you:

a) download RubyCLR - it runs on both 1.8.2 and 1.8.4
b) look at the unit tests - you'll find test cases that cover
virtually all scenarios
c) look at the sample applications - there are many, many sample
applications that cover a lot of the common scenarios (like
databinding ActiveRecord objects to data aware controls).
d) Google is your friend - read my blog entries and you'll see the
entire history of RubyCLR's implementation laid out.

If you have specific questions, feel free to post back here.

-John
http://www.iu...


On 8/25/06, Patrick Spence <patrick@pkspence.com> wrote:
> I have a "COM enabled" C# .NET .dll. I need to instanciate it in some
> Ruby code. Has anyone done something like this? If so, how? It doesn't
> seem to be as straight forward as a VB6 COM .dll.
>
> --
> Posted via http://www.ruby-....
>
>