# Up-to-date hosting sample?

**URL:** <https://www.ruby-forum.com/t/up-to-date-hosting-sample/125143>\
**Category:** IronRuby\
**Created:** [January 6, 2008, 4:33am UTC](https://www.ruby-forum.com/t/up-to-date-hosting-sample/125143 "2008-01-06T04:33:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [January 6, 2008, 4:33am UTC](https://www.ruby-forum.com/t/up-to-date-hosting-sample/125143/1 "2008-01-06T04:33:40Z")

</div>

Hi!

I’m preparing an IronRuby article for a french newspaper, and would  
like to demonstrate the hosting features (possibly to show how to  
build a small dsl to script a C# application for instance).

I’m sitting on SVN at revision 68 but can’t get the wiki sample [1] to  
compile - I believe the hosting stuff is currently under heavy  
modification, right ?

Does anyone have an up-to-date hosting sample, or should I go back a  
few revisions ?

cheers!

[1]  
[http://ironruby.rubyforge.org/wiki/wiki.pl?ExecutingIronRubyFromCSharp](http://ironruby.rubyforge.org/wiki/wiki.pl?ExecutingIronRubyFromCSharp)

## Thibaut Barrère

LoGeek  
[http://evolvingworker.com](http://evolvingworker.com) - tools for a better day  
[http://blog.logeek.fr](http://blog.logeek.fr) - about writing software

---

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [January 7, 2008, 8:17am UTC](https://www.ruby-forum.com/t/up-to-date-hosting-sample/125143/2 "2008-01-07T08:17:05Z")

</div>

You’re right. The Hosting API is currently under (re)construction.  
Therefore the example is currently not so nice:

```
        IScriptEnvironment runtime = 

```

ScriptEnvironment.GetEnvironment();  
IScriptEngine engine = IronRuby.GetEngine(runtime);  
IScriptScope scope = engine.CreateScope();

```
        List<string> strings = new List<string>();
        strings.Add("one");
        strings.Add("two");
        IronRuby.GetExecutionContext(runtime).GlobalVariables[SymbolTable.StringToId("strings")] 

```

= strings;

```
        SourceUnit script = engine.CreateScriptSourceFromString(

```

@"  
puts ““Hello World! There are #{$strings.count.to\_s} strings:””  
$strings.each\_with\_index { |s,i| puts “”#{i}: #{s}"" }  
");  
engine.Execute(scope, script);

It will get better soon.

Tomas

---

<div class="post-metadata">

**Author:** ![thbar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/eb8c5e/32.png) [@thbar](https://www.ruby-forum.com/u/thbar)\
**Post date:** [January 7, 2008, 10:29am UTC](https://www.ruby-forum.com/t/up-to-date-hosting-sample/125143/3 "2008-01-07T10:29:55Z")

</div>

Hi Tomas,

thanks for your answer ! That will be nice enough 🙂

## Thibaut Barrère

LoGeek  
[http://evolvingworker.com](http://evolvingworker.com) - tools for a better day  
[http://blog.logeek.fr](http://blog.logeek.fr) - about writing software
