[Ironruby-core] setting global variables in embedded ironruby interpreter

Meinrad Recheis meinrad.recheis at gmail.com
Mon Feb 9 07:11:34 EST 2009


On Mon, Feb 9, 2009 at 1:05 PM, Meinrad Recheis
<meinrad.recheis at gmail.com>wrote:

> On Mon, Feb 9, 2009 at 12:12 PM, Meinrad Recheis <
> meinrad.recheis at gmail.com> wrote:
>
>> Hello,
>>
>> I am very pleased that I got everything working and found iron ruby in a
>> quite usable state for me. Congratulations.
>>
>> Question: How do you set a global variable from C#? I found a workaround
>> via setting a local variable scope.SetVariable("a", obj) in the scope and
>> assigning it to a global via engine.Execute("$a=a", scope).
>> The Runtime.Globals.GetVariable and SetVariable don't seem to get / set
>> the ruby globals.
>>
>
> Oh, i just found out that ScriptScope.GetVariable is throwing an exception
> ...
>
>
> ********************************************************************************
> ArgumentNullException: "Value cannot be null.
> Parameter name: field"
>
> --------------------------------------------------------------------------------
>   Microsoft.Scripting.Utils.ContractUtils.RequiresNotNull(Object value,
> String paramName)
>   Microsoft.Scripting.SymbolTable.StringToId(String field)
>   Microsoft.Scripting.Hosting.ScriptScope.GetVariable(String name)
>

sorry forgot to say, that I made sure, that the "name" parameter is *not*
null.
I am not yet deep enough into the sources to fix things like these myself.

-- henon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20090209/f65fdeb5/attachment.html>


More information about the Ironruby-core mailing list