# ScriptScope from IDictionary + function definitions = NotImplementedException

**URL:** <https://www.ruby-forum.com/t/scriptscope-from-idictionary-function-definitions-notimplementedexception/199207>\
**Category:** IronRuby\
**Created:** [November 16, 2010, 8:15pm UTC](https://www.ruby-forum.com/t/scriptscope-from-idictionary-function-definitions-notimplementedexception/199207 "2010-11-16T20:15:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![okkezSS](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/o/85f322/32.png) [@okkezSS](https://www.ruby-forum.com/u/okkezSS)\
**Post date:** [November 16, 2010, 8:15pm UTC](https://www.ruby-forum.com/t/scriptscope-from-idictionary-function-definitions-notimplementedexception/199207/1 "2010-11-16T20:15:25Z")

</div>

Hi all!

I’m running ruby script from C# in my project. It’s a very useful  
feature to  
initialize ScriptScope with an IDictionary, (it’s much faster to fill a  
dictionary, than making scope.SetVariable calls).

The problem is, that if I define functions in my script, then a  
NotImplementedException is thrown.

A simple example is here: [No description - C# Paste](http://paste.dprogramming.com/dpil37pp)  
It fails at engine.Execute(script, scope). However, when I create my  
scope  
with no dictionary, or just pass no scope to Execute, everything works  
fine.

Is it an issue to be fixed in the future?  
I need to set, and change many context variables for my scripts at  
running  
time, so I have to work out this problem somehow.  
I’m using IronRuby 1.1.

Thanks:  
Anton

---

<div class="post-metadata">

**Author:** ![Anton\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6de8d8/32.png) [@Anton\_F](https://www.ruby-forum.com/u/Anton_F)\
**Post date:** [November 21, 2010, 9:29pm UTC](https://www.ruby-forum.com/t/scriptscope-from-idictionary-function-definitions-notimplementedexception/199207/2 "2010-11-21T21:29:14Z")

</div>

I’ve just added support for string dictionaries. It’s committed to the  
github repo.

Tomas

From: removed\_email\_address@domain.invalid  
[[mailto:removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)] On Behalf Of Anton F.  
Sent: Tuesday, November 16, 2010 10:05 AM  
To: removed\_email\_address@domain.invalid  
Subject: [Ironruby-core] ScriptScope from IDictionary + function  
definitions = NotImplementedException

Hi all!

I’m running ruby script from C# in my project. It’s a very useful  
feature to initialize ScriptScope with an IDictionary, (it’s much faster  
to fill a dictionary, than making scope.SetVariable calls).

The problem is, that if I define functions in my script, then a  
NotImplementedException is thrown.

A simple example is here: [No description - C# Paste](http://paste.dprogramming.com/dpil37pp)  
It fails at engine.Execute(script, scope). However, when I create my  
scope with no dictionary, or just pass no scope to Execute, everything  
works fine.

Is it an issue to be fixed in the future?  
I need to set, and change many context variables for my scripts at  
running time, so I have to work out this problem somehow.  
I’m using IronRuby 1.1.

Thanks:  
Anton

---

<div class="post-metadata">

**Author:** ![Anton\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/6de8d8/32.png) [@Anton\_F](https://www.ruby-forum.com/u/Anton_F)\
**Post date:** [November 25, 2010, 2:19pm UTC](https://www.ruby-forum.com/t/scriptscope-from-idictionary-function-definitions-notimplementedexception/199207/3 "2010-11-25T14:19:21Z")

</div>

Very nice, Thanks!

There is another error related to scopes, here is a code to reproduce  
it:  
[http://paste.dprogramming.com/dpw8o44y](http://paste.dprogramming.com/dpw8o44y)  
It throws NullReferenceException for me. When I executed the commented  
lines  
(using no scope), no exception was thrown.

Anton

2010/11/21 Tomas M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
