<div dir="ltr">Does it work correctly under NUnit if you disable shadow copying?<br><br><div class="gmail_quote">On Mon, Sep 29, 2008 at 10:41 AM, Fernando Correia <span dir="ltr">&lt;<a href="mailto:fernandoacorreia@gmail.com">fernandoacorreia@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;">Dino, thanks for your support.<br>
<br>
The modified code still aborts under NUnit, so it is not related to<br>
the configuration. The program runs correctly outside NUnit, but<br>
raises an InvalidProgramException when executed as a unit test.<br>
<br>
I had a similar problem with a previous version of IronPython that<br>
disappeared in another release. Granted that NUnit must be doing<br>
something to the execution context, but it would really be a shame if<br>
code that uses IronPython could not be tested under NUnit.<br>
<br>
Please notice that until Beta 4 this kind of test was working. The<br>
exception started with Beta 5.<br>
<br>
Regards.<br>
<br>
using System;<br>
using System.Collections.Generic;<br>
using System.Diagnostics;<br>
using System.Text;<br>
using Microsoft.Scripting.Hosting;<br>
using Microsoft.Scripting;<br>
using IronPython.Hosting;<br>
using NUnit.Framework;<br>
<br>
namespace HelloDLRWorld<br>
{<br>
 &nbsp; &nbsp;[TestFixture]<br>
 &nbsp; &nbsp;public class DlrTest2<br>
 &nbsp; &nbsp;{<br>
 &nbsp; &nbsp; &nbsp; &nbsp;public static void Main(string[] args)<br>
 &nbsp; &nbsp; &nbsp; &nbsp;{<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;var test = new DlrTest2();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;test.ImportTest();<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
<br>
 &nbsp; &nbsp; &nbsp; &nbsp;[Test]<br>
 &nbsp; &nbsp; &nbsp; &nbsp;public void ImportTest()<br>
 &nbsp; &nbsp; &nbsp; &nbsp;{<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptRuntime runtime = Python.CreateRuntime();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;runtime.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;runtime.LoadAssembly(typeof(System.Double).Assembly);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptEngine pyEng = runtime.GetEngine(&quot;IronPython&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptSource source = pyEng.CreateScriptSourceFromString(@&quot;<br>
import System.Diagnostics<br>
output=&#39;hello world from DLR/IronPython!&#39;<br>
System.Diagnostics.Debug.WriteLine(output)<br>
&quot;, SourceCodeKind.Statements);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptScope scope = pyEng.CreateScope();<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;source.Execute(scope);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;object outputMsg = scope.GetVariable(&quot;output&quot;);<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Console.WriteLine(outputMsg.ToString());<br>
 &nbsp; &nbsp; &nbsp; &nbsp;}<br>
 &nbsp; &nbsp;}<br>
}<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>
</blockquote></div><br></div>