<div>Is IronPython.Modules.dll referenced by the host app?</div><br clear="all">~Jimmy<br>
<br><br><div class="gmail_quote">On Tue, Mar 15, 2011 at 12:22 PM, Slide <span dir="ltr">&lt;<a href="mailto:slide.o.mix@gmail.com">slide.o.mix@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">

I am embedding IronPython in my app to allow some script capabilities.<br>
I have the following code:<br>
<br>
_content = content.Trim();<br>
<br>
            string script = string.Format(@&quot;<br>
import re<br>
<br>
def interp(string, variables):<br>
    globals = globals()<br>
    for item in re.findall(r&#39;\$\(([^{{]*)\)&#39;, string):<br>
        string = string.replace(&#39;$(%s)&#39; % item,<br>
                            str(eval(item, globals, variables)))<br>
    return string<br>
<br>
{0}<br>
&quot;, _content);<br>
<br>
            try<br>
            {<br>
                _engine = Python.CreateEngine();<br>
                List&lt;string&gt; searchPaths = new<br>
List&lt;string&gt;(_engine.GetSearchPaths());<br>
                searchPaths.Add(<br>
<br>
Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));<br>
<br>
                _engine.SetSearchPaths(searchPaths);<br>
                ScriptSource source =<br>
                    _engine.CreateScriptSourceFromString(script);<br>
<br>
                _script = source.Compile();<br>
            }<br>
            catch(SyntaxErrorException ex)<br>
            {<br>
                ExceptionOperations eo =<br>
                    _engine.GetService&lt;ExceptionOperations&gt;();<br>
                throw new ScriptedStringParseException(<br>
                    eo.FormatException(ex), -1);<br>
            }<br>
<br>
Then later I call:<br>
<br>
_script.DefaultScope.SetVariable(&quot;context&quot;,<br>
                GenerateParameters(context));<br>
            return _script.Execute&lt;string&gt;();<br>
<br>
The problem I am running into is that _script.Execute is that I am<br>
getting an import exception on the &quot;import re&quot;<br>
<br>
re is a builtin module, so I am not sure why that is happening, does<br>
the IronPython.Modules.dll need to be in the DLLs directory? I don&#39;t<br>
remember having this issue previously.<br>
<font color="#888888"><br>
--<br>
slide-o-blog<br>
<a href="http://slide-o-blog.blogspot.com/" target="_blank">http://slide-o-blog.blogspot.com/</a><br>
_______________________________________________<br>
Users mailing list<br>
<a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>
</font></blockquote></div><br>