Works like a charm, thank you.<br><br><div><span class="gmail_quote">On 9/22/08, <b class="gmail_sendername">Michael Foord</b> &lt;<a href="mailto:fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>&gt; wrote:</span><blockquote class="gmail_quote" style="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0; margin-left: 0.80ex; border-left-color: #cccccc; border-left-width: 1px; border-left-style: solid; padding-left: 1ex">
<span class="q">Ronnie Maor wrote:<br><blockquote class="gmail_quote" style="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0.80ex; border-left-color: #cccccc; border-left-width: 1px; border-left-style: solid; padding-left: 1ex">
 I get the same problem.<br><br> Another symptom is that &quot;import System&quot; fails if you don&#39;t AddReference first. never needed to do that for IPy 1.1 and don&#39;t need to either when running ipy 2.0.<br><br></blockquote>
<br></span> When embedding IronPython you need to add references to both &#39;System.dll&#39; and &#39;mscorlib.dll&#39;. This is done for you in the console, but not when embedding IronPython.<br><br> You can do this using the &#39;LoadAssembly&#39; method of the ScriptRuntime:<br>
<br> _runtime.LoadAssembly(typeof(String).Assembly);<br> _runtime.LoadAssembly(typeof(Uri).Assembly);<br><br> Michael<br><br><blockquote class="gmail_quote" style="margin-top: 0; margin-right: 0; margin-bottom: 0; margin-left: 0.80ex; border-left-color: #cccccc; border-left-width: 1px; border-left-style: solid; padding-left: 1ex">
<span class="q"> It fails with my hosting code, and also reproduces with the &quot;hello world&quot; hosting sample:<br><a href="http://blogs.msdn.com/seshadripv/archive/2008/09/11/dlr-hosting-sample-simple-dlr-host-using-the-new-app-config-based-scriptruntime-creation.aspx" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://blogs.msdn.com/seshadripv/archive/2008/09/11/dlr-hosting-sample-simple-dlr-host-using-the-new-app-config-based-scriptruntime-creation.aspx</a><br>
<br> The only changes I made to the sample were<br> 1) delete ruby configuration from App.config and the line of code that builds a ruby engine (I don&#39;t have the assemblies for ruby)<br> 2) change the line defining the source code to:<br>
  &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;ScriptSource source = pyEng.CreateScriptSourceFromString(@&quot;import System&quot;, SourceCodeKind.Statements);<br> 3) remove the code that gets the &quot;output&quot; variable from pyEng (since we don&#39;t produce it)<br>
<br> like I said, this fails with &quot;No module named System&quot;.<br> If you add a clr.AddReference(&quot;System&quot;), then import works, but dir() seems to only show namespaces and not types, so import System.DateTime will fail.<br>
<br> I&#39;m now looking at sources for IronPythonConsole to see what the difference is, but if someone knows what I&#39;m doing wrong, please tell...<br><br> thanks<br> Ronnie<br><br></span><div><span class="e" id="q_11c856dc4d840a1c_3"> On Sun, Sep 21, 2008 at 8:31 AM, Serge R &lt;<a href="mailto:deus.verus@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">deus.verus@gmail.com</a> &lt;mailto:<a href="mailto:deus.verus@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">deus.verus@gmail.com</a>&gt;&gt; wrote:<br>
<br>  &nbsp; &nbsp;I am migrating from 1.1 and have been unable to import System.Math<br>  &nbsp; &nbsp;class. I took a look at what&#39;s actually been imported<br><br>  &nbsp; &nbsp;clr.AddReference(&quot;System&quot;)<br>  &nbsp; &nbsp;import System<br>  &nbsp; &nbsp;print dir(System)<br>
<br>  &nbsp; &nbsp;On IP2 I got a small list that didn&#39;t contain Math or many other<br>  &nbsp; &nbsp;classes. Am I referencing something wrong?<br><br>  &nbsp; &nbsp;IP2 List:<br>  &nbsp; &nbsp;[&#39;CodeDom&#39;, &#39;Collections&#39;, &#39;ComponentModel&#39;, &#39;Configuration&#39;,<br>
  &nbsp; &nbsp;&#39;Diagnostics&#39;, &#39;FileStyleUriParser&#39;, &#39;FtpStyleUriParser&#39;,<br>  &nbsp; &nbsp;&#39;GenericUriParser&#39;, &#39;GenericUriParserOptions&#39;,<br>  &nbsp; &nbsp;&#39;GopherStyleUriParser&#39;, &#39;HttpStyleUriParser&#39;, &#39;IO&#39;,<br>
  &nbsp; &nbsp;&#39;LdapStyleUriParser&#39;, &#39;Media&#39;, &#39;Net&#39;, &#39;NetPipeStyleUriParser&#39;,<br>  &nbsp; &nbsp;&#39;NetTcpStyleUriParser&#39;, &#39;NewsStyleUriParser&#39;, &#39;Runtime&#39;,<br>  &nbsp; &nbsp;&#39;Security&#39;, &#39;Text&#39;, &#39;Threading&#39;, &#39;Timers&#39;, &#39;Uri&#39;, &#39;UriBuilder&#39;,<br>
  &nbsp; &nbsp;&#39;UriComponents&#39;, &#39;UriFormat&#39;, &#39;UriFormatException&#39;,<br>  &nbsp; &nbsp;&#39;UriHostNameType&#39;, &#39;UriIdnScope&#39;, &#39;UriKind&#39;, &#39;UriParser&#39;,<br>  &nbsp; &nbsp;&#39;UriPartial&#39;, &#39;UriTypeConverter&#39;, &#39;Web&#39;]<br>
<br>  &nbsp; &nbsp;IP1 List:<br>  &nbsp; &nbsp;[&#39;AccessViolationException&#39;, &#39;Action&#39;, &#39;ActivationContext&#39;,<br>  &nbsp; &nbsp;&#39;Activator&#39;, &#39;AppDomain&#39;, &#39;AppDomainInitializer&#39;,<br>  &nbsp; &nbsp;&#39;AppDomainManager&#39;, &#39;AppDomainManagerInitializationOptions&#39;,<br>
  &nbsp; &nbsp;&#39;AppDomainSetup&#39;, &#39;AppDomainUnloadedException&#39;,<br>  &nbsp; &nbsp;&#39;ApplicationException&#39;, &#39;ApplicationId&#39;, &#39;ApplicationIdentity&#39;,<br>  &nbsp; &nbsp;&#39;ArgIterator&#39;, &#39;ArgumentException&#39;, &#39;ArgumentNullException&#39;,<br>
  &nbsp; &nbsp;&#39;ArgumentOutOfRangeException&#39;, &#39;ArithmeticException&#39;, &#39;Array&#39;,<br>  &nbsp; &nbsp;&#39;ArraySegment&#39;, &#39;ArrayTypeMismatchException&#39;,<br>  &nbsp; &nbsp;&#39;AssemblyLoadEventArgs&#39;, &#39;AssemblyLoadEventHandler&#39;,<br>
  &nbsp; &nbsp;&#39;AsyncCallback&#39;, &#39;Attribute&#39;, &#39;AttributeTargets&#39;,<br>  &nbsp; &nbsp;&#39;AttributeUsageAttribute&#39;, &#39;BadImageFormatException&#39;,<br>  &nbsp; &nbsp;&#39;Base64FormattingOptions&#39;, &#39;BitConverter&#39;, &#39;Boolean&#39;, &#39;Buffer&#39;,<br>
  &nbsp; &nbsp;&#39;Byte&#39;, &#39;CLSCompliantAttribute&#39;, &#39;CannotUnloadAppDomainException&#39;,<br>  &nbsp; &nbsp;&#39;Char&#39;, &#39;CharEnumerator&#39;, &#39;CodeDom&#39;, &#39;Collections&#39;, &#39;Comparison&#39;,<br>  &nbsp; &nbsp;&#39;ComponentModel&#39;, &#39;Configuration&#39;, &#39;Console&#39;,<br>
  &nbsp; &nbsp;&#39;ConsoleCancelEventArgs&#39;, &#39;ConsoleCancelEventHandler&#39;,<br>  &nbsp; &nbsp;&#39;ConsoleColor&#39;, &#39;ConsoleKey&#39;, &#39;ConsoleKeyInfo&#39;,<br>  &nbsp; &nbsp;&#39;ConsoleModifiers&#39;, &#39;ConsoleSpecialKey&#39;, &#39;ContextBoundObject&#39;,<br>
  &nbsp; &nbsp;&#39;ContextMarshalException&#39;, &#39;ContextStaticAttribute&#39;, &#39;Convert&#39;,<br>  &nbsp; &nbsp;&#39;Converter&#39;, &#39;CrossAppDomainDelegate&#39;, &#39;DBNull&#39;,<br>  &nbsp; &nbsp;&#39;DataMisalignedException&#39;, &#39;DateTime&#39;, &#39;DateTimeKind&#39;,<br>
  &nbsp; &nbsp;&#39;DateTimeOffset&#39;, &#39;DayOfWeek&#39;, &#39;Decimal&#39;, &#39;Delegate&#39;,<br>  &nbsp; &nbsp;&#39;Deployment&#39;, &#39;Diagnostics&#39;, &#39;DivideByZeroException&#39;,<br>  &nbsp; &nbsp;&#39;DllNotFoundException&#39;, &#39;Double&#39;, &#39;DuplicateWaitObjectException&#39;,<br>
  &nbsp; &nbsp;&#39;EntryPointNotFoundException&#39;, &#39;Enum&#39;, &#39;Environment&#39;,<br>  &nbsp; &nbsp;&#39;EnvironmentVariableTarget&#39;, &#39;EventArgs&#39;, &#39;EventHandler&#39;,<br>  &nbsp; &nbsp;&#39;Exception&#39;, &#39;ExecutionEngineException&#39;, &#39;FieldAccessException&#39;,<br>
  &nbsp; &nbsp;&#39;FileStyleUriParser&#39;, &#39;FlagsAttribute&#39;, &#39;FormatException&#39;,<br>  &nbsp; &nbsp;&#39;FtpStyleUriParser&#39;, &#39;GC&#39;, &#39;GCCollectionMode&#39;, &#39;GenericUriParser&#39;,<br>  &nbsp; &nbsp;&#39;GenericUriParserOptions&#39;, &#39;Globalization&#39;,<br>
  &nbsp; &nbsp;&#39;GopherStyleUriParser&#39;, &#39;Guid&#39;, &#39;HttpStyleUriParser&#39;,<br>  &nbsp; &nbsp;&#39;IAppDomainSetup&#39;, &#39;IAsyncResult&#39;, &#39;ICloneable&#39;, &#39;IComparable&#39;,<br>  &nbsp; &nbsp;&#39;IConvertible&#39;, &#39;ICustomFormatter&#39;, &#39;IDisposable&#39;, &#39;IEquatable&#39;,<br>
  &nbsp; &nbsp;&#39;IFormatProvider&#39;, &#39;IFormattable&#39;, &#39;IO&#39;, &#39;IServiceProvider&#39;,<br>  &nbsp; &nbsp;&#39;IndexOutOfRangeException&#39;, &#39;InsufficientMemoryException&#39;,<br>  &nbsp; &nbsp;&#39;Int16&#39;, &#39;Int32&#39;, &#39;Int64&#39;, &#39;IntPtr&#39;, &#39;InvalidCastException&#39;,<br>
  &nbsp; &nbsp;&#39;InvalidOperationException&#39;, &#39;InvalidProgramException&#39;,<br>  &nbsp; &nbsp;&#39;LdapStyleUriParser&#39;, &#39;LoaderOptimization&#39;,<br>  &nbsp; &nbsp;&#39;LoaderOptimizationAttribute&#39;, &#39;LocalDataStoreSlot&#39;,<br>
  &nbsp; &nbsp;&#39;MTAThreadAttribute&#39;, &#39;MarshalByRefObject&#39;, &#39;Math&#39;, &#39;Media&#39;,<br>  &nbsp; &nbsp;&#39;MemberAccessException&#39;, &#39;MethodAccessException&#39;,<br>  &nbsp; &nbsp;&#39;MidpointRounding&#39;, &#39;MissingFieldException&#39;,<br>
  &nbsp; &nbsp;&#39;MissingMemberException&#39;, &#39;MissingMethodException&#39;,<br>  &nbsp; &nbsp;&#39;ModuleHandle&#39;, &#39;MulticastDelegate&#39;,<br>  &nbsp; &nbsp;&#39;MulticastNotSupportedException&#39;, &#39;Net&#39;, &#39;NetPipeStyleUriParser&#39;,<br>
  &nbsp; &nbsp;&#39;NetTcpStyleUriParser&#39;, &#39;NewsStyleUriParser&#39;,<br>  &nbsp; &nbsp;&#39;NonSerializedAttribute&#39;, &#39;NotFiniteNumberException&#39;,<br>  &nbsp; &nbsp;&#39;NotImplementedException&#39;, &#39;NotSupportedException&#39;,<br>
  &nbsp; &nbsp;&#39;NullReferenceException&#39;, &#39;Nullable&#39;, &#39;Object&#39;,<br>  &nbsp; &nbsp;&#39;ObjectDisposedException&#39;, &#39;ObsoleteAttribute&#39;, &#39;OperatingSystem&#39;,<br>  &nbsp; &nbsp;&#39;OperationCanceledException&#39;, &#39;OutOfMemoryException&#39;,<br>
  &nbsp; &nbsp;&#39;OverflowException&#39;, &#39;ParamArrayAttribute&#39;, &#39;PlatformID&#39;,<br>  &nbsp; &nbsp;&#39;PlatformNotSupportedException&#39;, &#39;Predicate&#39;, &#39;Random&#39;,<br>  &nbsp; &nbsp;&#39;RankException&#39;, &#39;Reflection&#39;, &#39;ResolveEventArgs&#39;,<br>
  &nbsp; &nbsp;&#39;ResolveEventHandler&#39;, &#39;Resources&#39;, &#39;Runtime&#39;,<br>  &nbsp; &nbsp;&#39;RuntimeArgumentHandle&#39;, &#39;RuntimeFieldHandle&#39;,<br>  &nbsp; &nbsp;&#39;RuntimeMethodHandle&#39;, &#39;RuntimeTypeHandle&#39;, &#39;SByte&#39;,<br>
  &nbsp; &nbsp;&#39;STAThreadAttribute&#39;, &#39;Security&#39;, &#39;SerializableAttribute&#39;,<br>  &nbsp; &nbsp;&#39;Single&#39;, &#39;StackOverflowException&#39;, &#39;String&#39;, &#39;StringComparer&#39;,<br>  &nbsp; &nbsp;&#39;StringComparison&#39;, &#39;StringSplitOptions&#39;, &#39;SystemException&#39;,<br>
  &nbsp; &nbsp;&#39;Text&#39;, &#39;ThreadStaticAttribute&#39;, &#39;Threading&#39;, &#39;TimeSpan&#39;,<br>  &nbsp; &nbsp;&#39;TimeZone&#39;, &#39;TimeoutException&#39;, &#39;Timers&#39;, &#39;Type&#39;, &#39;TypeCode&#39;,<br>  &nbsp; &nbsp;&#39;TypeInitializationException&#39;, &#39;TypeLoadException&#39;,<br>
  &nbsp; &nbsp;&#39;TypeUnloadedException&#39;, &#39;TypedReference&#39;, &#39;UInt16&#39;, &#39;UInt32&#39;,<br>  &nbsp; &nbsp;&#39;UInt64&#39;, &#39;UIntPtr&#39;, &#39;UnauthorizedAccessException&#39;,<br>  &nbsp; &nbsp;&#39;UnhandledExceptionEventArgs&#39;, &#39;UnhandledExceptionEventHandler&#39;,<br>
  &nbsp; &nbsp;&#39;Uri&#39;, &#39;UriBuilder&#39;, &#39;UriComponents&#39;, &#39;UriFormat&#39;,<br>  &nbsp; &nbsp;&#39;UriFormatException&#39;, &#39;UriHostNameType&#39;, &#39;UriIdnScope&#39;, &#39;UriKind&#39;,<br>  &nbsp; &nbsp;&#39;UriParser&#39;, &#39;UriPartial&#39;, &#39;UriTypeConverter&#39;, &#39;ValueType&#39;,<br>
  &nbsp; &nbsp;&#39;Version&#39;, &#39;Void&#39;, &#39;WeakReference&#39;, &#39;Web&#39;, &#39;_AppDomain&#39;,<br>  &nbsp; &nbsp;&#39;__builtins__&#39;, &#39;__dict__&#39;, &#39;__name__&#39;]<br><br>  &nbsp; &nbsp;_______________________________________________<br>
  &nbsp; &nbsp;Users mailing list<br></span></div>  &nbsp; &nbsp;<a href="mailto:Users@lists.ironpython.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Users@lists.ironpython.com</a> &lt;mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Users@lists.ironpython.com</a>&gt;<span class="q"><br>
  &nbsp; &nbsp;<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br><br>
<br></span> ------------------------------------------------------------------------<span class="q"><br><br> _______________________________________________<br> Users mailing list<br><a href="mailto:Users@lists.ironpython.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br>  &nbsp;<br></span></blockquote>
<span class="sg"><br><br> -- <br><a href="http://www.ironpythoninaction.com/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.ironpythoninaction.com/</a><br><a href="http://www.voidspace.org.uk/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.voidspace.org.uk/</a><br>
<a href="http://www.trypython.org/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.trypython.org/</a><br><a href="http://www.ironpython.info/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.ironpython.info/</a><br>
<a href="http://www.theotherdelia.co.uk/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.theotherdelia.co.uk/</a><br><a href="http://www.resolverhacks.net/" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.resolverhacks.net/</a></span><div>
<span class="e" id="q_11c856dc4d840a1c_10"><br><br> _______________________________________________<br> Users mailing list<br><a href="mailto:Users@lists.ironpython.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br></span></div>
</blockquote></div><br>