# Using IronRuby from Ruby (newbie)

**URL:** <https://www.ruby-forum.com/t/using-ironruby-from-ruby-newbie/180756>\
**Category:** IronRuby\
**Created:** [December 28, 2009, 3:58pm UTC](https://www.ruby-forum.com/t/using-ironruby-from-ruby-newbie/180756 "2009-12-28T15:58:26Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![writeameer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/9de053/32.png) [@writeameer](https://www.ruby-forum.com/u/writeameer)\
**Post date:** [December 28, 2009, 3:58pm UTC](https://www.ruby-forum.com/t/using-ironruby-from-ruby-newbie/180756/1 "2009-12-28T15:58:26Z")

</div>

Hello,

I’m working in an environment that’s very Ruby heavy and I’ve never used  
ruby before. I need to be able to access Windows performance counters in  
from a Windows service is written in native Ruby (not IronRuby). I’m  
traditionally a C# and JAVA programmer.

I was wondering if it might be possible for Ruby to be able to access  
the .Net System.Diagnostics performance counters via IronRuby. Of  
course, if there’s a much simpler way I’m all ears.

I tried searching the forum and it seems my searching skills are not up  
to par and apologize if this has been already answered. Thanks in  
advance for any help.

Ameer.

---

<div class="post-metadata">

**Author:** ![writeameer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/9de053/32.png) [@writeameer](https://www.ruby-forum.com/u/writeameer)\
**Post date:** [December 28, 2009, 4:13pm UTC](https://www.ruby-forum.com/t/using-ironruby-from-ruby-newbie/180756/2 "2009-12-28T16:13:00Z")

</div>

You can access System.Diagnostics via IronRuby. However, you will have  
to  
use the IronRuby interpreter to run your native ruby code, which is  
something I guess you are not willing to do (yet).

Maybe you’d better look for a gem or a Ruby library that simplifies  
performance counter access…

Thanks,  
Shay.

* * *

Shay F.  
Author of IronRuby Unleashed  
[http://www.IronShay.com](http://www.IronShay.com)  
Follow me: [http://twitter.com/ironshay](http://twitter.com/ironshay)

---

<div class="post-metadata">

**Author:** ![writeameer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/9de053/32.png) [@writeameer](https://www.ruby-forum.com/u/writeameer)\
**Post date:** [December 28, 2009, 4:45pm UTC](https://www.ruby-forum.com/t/using-ironruby-from-ruby-newbie/180756/3 "2009-12-28T16:45:48Z")

</div>

To access the .NET framework from MRI (the Ruby implementation you are  
currently using), your best bet is to use RubyCLR:  
[http://rubyforge.org/projects/rubyclr/](http://rubyforge.org/projects/rubyclr/). It is a native bridge between  
Ruby and the CLR, using Ruby’s Win32OLE support to talk directly to the  
CLR hosting APIs.

~js

* * *

From: removed\_email\_address@domain.invalid  
[removed\_email\_address@domain.invalid] on behalf of Ameer D.  
[removed\_email\_address@domain.invalid]  
Sent: Monday, December 28, 2009 6:58 AM  
To: removed\_email\_address@domain.invalid  
Subject: [Ironruby-core] Using IronRuby from Ruby (newbie)

Hello,

I’m working in an environment that’s very Ruby heavy and I’ve never used  
ruby before. I need to be able to access Windows performance counters in  
from a Windows service is written in native Ruby (not IronRuby). I’m  
traditionally a C# and JAVA programmer.

I was wondering if it might be possible for Ruby to be able to access  
the .Net System.Diagnostics performance counters via IronRuby. Of  
course, if there’s a much simpler way I’m all ears.

I tried searching the forum and it seems my searching skills are not up  
to par and apologize if this has been already answered. Thanks in  
advance for any help.

## Ameer.

Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).

* * *

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:** ![writeameer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/9de053/32.png) [@writeameer](https://www.ruby-forum.com/u/writeameer)\
**Post date:** [December 30, 2009, 3:00am UTC](https://www.ruby-forum.com/t/using-ironruby-from-ruby-newbie/180756/4 "2009-12-30T03:00:21Z")

</div>

Shay F. wrote:

> You can access System.Diagnostics via IronRuby. However, you will have  
> to  
> use the IronRuby interpreter to run your native ruby code, which is  
> something I guess you are not willing to do (yet).
> 
> Maybe you’d better look for a gem or a Ruby library that simplifies  
> performance counter access…
> 
> Thanks,  
> Shay.
> 
> * * *
> 
> Shay F.  
> Author of IronRuby Unleashed  
> [http://www.IronShay.com](http://www.IronShay.com)  
> Follow me: [http://twitter.com/ironshay](http://twitter.com/ironshay)

Hi there Shay,

I’m not sure if I can run this existing ruby service (called collectd)  
on IronRuby instead and I need to investigate that so your right about  
the yet :). I’ll see if I can find a gem that can do what I’m looking  
for. Thanks for the help.

Ameer.

---

<div class="post-metadata">

**Author:** ![writeameer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/9de053/32.png) [@writeameer](https://www.ruby-forum.com/u/writeameer)\
**Post date:** [December 30, 2009, 3:03am UTC](https://www.ruby-forum.com/t/using-ironruby-from-ruby-newbie/180756/5 "2009-12-30T03:03:41Z")

</div>

Hi there Jimmy,

This looks very promising. Thanks very much for the pointer.

Ameer.

Jimmy S. wrote:

> To access the .NET framework from MRI (the Ruby implementation you are  
> currently using), your best bet is to use RubyCLR:  
> [http://rubyforge.org/projects/rubyclr/](http://rubyforge.org/projects/rubyclr/). It is a native bridge between  
> Ruby and the CLR, using Ruby’s Win32OLE support to talk directly to the  
> CLR hosting APIs.
> 
> ~js

---

<div class="post-metadata">

**Author:** ![writeameer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/9de053/32.png) [@writeameer](https://www.ruby-forum.com/u/writeameer)\
**Post date:** [December 30, 2009, 11:41am UTC](https://www.ruby-forum.com/t/using-ironruby-from-ruby-newbie/180756/6 "2009-12-30T11:41:10Z")

</div>

To high speed access the .NET framework from Ruby you can write own Ruby  
extension on C++/CLI. So you can create custom wrapper for .NET class  
and optimize them for your needs.

---

<div class="post-metadata">

**Author:** ![writeameer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/9de053/32.png) [@writeameer](https://www.ruby-forum.com/u/writeameer)\
**Post date:** [December 30, 2009, 11:39pm UTC](https://www.ruby-forum.com/t/using-ironruby-from-ruby-newbie/180756/7 "2009-12-30T23:39:23Z")

</div>

Yeah, RubyCLR is that.

---

<div class="post-metadata">

**Author:** ![writeameer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/9de053/32.png) [@writeameer](https://www.ruby-forum.com/u/writeameer)\
**Post date:** [January 2, 2010, 3:52am UTC](https://www.ruby-forum.com/t/using-ironruby-from-ruby-newbie/180756/8 "2010-01-02T03:52:10Z")

</div>

Hi there Shay,

Using IronRuby to run the ruby code turned out to be easier than I  
thought. I’m able to run the code on IronRuby and access the  
System.Diagnostics namespace. Thanks very much for your help.

Ameer.

Shay F. wrote:

> You can access System.Diagnostics via IronRuby. However, you will have  
> to  
> use the IronRuby interpreter to run your native ruby code, which is  
> something I guess you are not willing to do (yet).
> 
> Maybe you’d better look for a gem or a Ruby library that simplifies  
> performance counter access…
> 
> Thanks,  
> Shay.
> 
> * * *
> 
> Shay F.  
> Author of IronRuby Unleashed  
> [http://www.IronShay.com](http://www.IronShay.com)  
> Follow me: [http://twitter.com/ironshay](http://twitter.com/ironshay)
