Invoke .NET objects from Ruby

B

Bill Atkins

I have a DLL assembly containing some classes I wrote in C#, and I'd
like to be able to use these objects from a Ruby script (not from
a .NET Ruby implementation, but from plain old MRI).

Is this possible?
 
H

Huw Collingbourne

Bill said:
I have a DLL assembly containing some classes I wrote in C#, and I'd
like to be able to use these objects from a Ruby script (not from
a .NET Ruby implementation, but from plain old MRI).

Is this possible?

I'm not sure if this is of any use to you, but we have a free control,
The Ruby Connector, which lets you go the other way around - that is,
create an application in .NET and run Ruby simultaneous with it, passing
messages from .NET to Ruby and receiving replies from your Ruby programs
which can then be used in the .NET application...

You can download that here:
http://www.sapphiresteel.com/SapphireSteel-Downloads

best wishes
Huw

SapphireSteel Software
Ruby and Rails In Visual Studio
http://www.sapphiresteel.com
 
M

Manish Sapariya

This might do it:
Can I use rubyclr to automate .NET GUI application. We are currently
writing a XML-RPC to drive our GUI Classes by writing dummy app over our
application back-end, and just test backend part of the application.
However I would want to drive the application from GUI if possible.

I am aware of autoit and other GUI automation tools, however, it would
be great if there is some native support by .NET which can be used by
using rubyclr.

Any ideas?
Thanks and Regards,
Manish
 
K

Kyle Schmitt

Bill,
If this is on a windows box, which I'm gonna assume since I dunno how
I'd do this with a real os + mono, just use win32ole to create the object.

I've used several homemade .net classes from vbscript before, and I've
played with them in ruby, but only went so far as to see it was possible.

More or less it's using it just like any other windows class. I don't have any
of my old backups on hand, so I can't copy out examples, but look at the
ones in the ruby win32ole docs, and look at the [vb/j]script examples on
the msdn site.

--Kyle
 
C

Clifford Heath

Bill said:
I have a DLL assembly containing some classes I wrote in C#, and I'd
like to be able to use these objects from a Ruby script (not from
a .NET Ruby implementation, but from plain old MRI).

Is this possible?

I believe that DotNET provides a COM interface for any DotNET class.
I forget the details; there will be issues with funky data types,
but in general, Win32OLE can get to COM objects.
 
K

Kyle Schmitt

I believe that DotNET provides a COM interface for any DotNET class.
I forget the details; there will be issues with funky data types,
but in general, Win32OLE can get to COM objects.

Cliff,
.Net objects can be accessed via the COM interface, and it's a
good way to use it. The down side (and it's a really big down side..)
for the COM interface, is that (if I'm recalling this correctly, it's
been awhile) a non .Net program calling a .Net class has the same
triple call overhead that a .Net app has calling a non .Net class.
Literally there is a three call overhead for each time you call from
one to the other. Not a problem if the class you're calling is doing
all the heavy lifting, or you need a quick and dirty solution, but
nasty for a lot of things.

--Kyle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,996
Messages
2,570,238
Members
46,826
Latest member
robinsontor

Latest Threads

Top