Works like a charm, thank you.<br><br><div><span class="gmail_quote">On 9/22/08, <b class="gmail_sendername">Michael Foord</b> <<a href="mailto:fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>> 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 "import System" fails if you don't AddReference first. never needed to do that for IPy 1.1 and don't need to either when running ipy 2.0.<br><br></blockquote>
<br></span> When embedding IronPython you need to add references to both 'System.dll' and 'mscorlib.dll'. This is done for you in the console, but not when embedding IronPython.<br><br> You can do this using the 'LoadAssembly' 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 "hello world" 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't have the assemblies for ruby)<br> 2) change the line defining the source code to:<br>
ScriptSource source = pyEng.CreateScriptSourceFromString(@"import System", SourceCodeKind.Statements);<br> 3) remove the code that gets the "output" variable from pyEng (since we don't produce it)<br>
<br> like I said, this fails with "No module named System".<br> If you add a clr.AddReference("System"), then import works, but dir() seems to only show namespaces and not types, so import System.DateTime will fail.<br>
<br> I'm now looking at sources for IronPythonConsole to see what the difference is, but if someone knows what I'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 <<a href="mailto:deus.verus@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">deus.verus@gmail.com</a> <mailto:<a href="mailto:deus.verus@gmail.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">deus.verus@gmail.com</a>>> wrote:<br>
<br> I am migrating from 1.1 and have been unable to import System.Math<br> class. I took a look at what's actually been imported<br><br> clr.AddReference("System")<br> import System<br> print dir(System)<br>
<br> On IP2 I got a small list that didn't contain Math or many other<br> classes. Am I referencing something wrong?<br><br> IP2 List:<br> ['CodeDom', 'Collections', 'ComponentModel', 'Configuration',<br>
'Diagnostics', 'FileStyleUriParser', 'FtpStyleUriParser',<br> 'GenericUriParser', 'GenericUriParserOptions',<br> 'GopherStyleUriParser', 'HttpStyleUriParser', 'IO',<br>
'LdapStyleUriParser', 'Media', 'Net', 'NetPipeStyleUriParser',<br> 'NetTcpStyleUriParser', 'NewsStyleUriParser', 'Runtime',<br> 'Security', 'Text', 'Threading', 'Timers', 'Uri', 'UriBuilder',<br>
'UriComponents', 'UriFormat', 'UriFormatException',<br> 'UriHostNameType', 'UriIdnScope', 'UriKind', 'UriParser',<br> 'UriPartial', 'UriTypeConverter', 'Web']<br>
<br> IP1 List:<br> ['AccessViolationException', 'Action', 'ActivationContext',<br> 'Activator', 'AppDomain', 'AppDomainInitializer',<br> 'AppDomainManager', 'AppDomainManagerInitializationOptions',<br>
'AppDomainSetup', 'AppDomainUnloadedException',<br> 'ApplicationException', 'ApplicationId', 'ApplicationIdentity',<br> 'ArgIterator', 'ArgumentException', 'ArgumentNullException',<br>
'ArgumentOutOfRangeException', 'ArithmeticException', 'Array',<br> 'ArraySegment', 'ArrayTypeMismatchException',<br> 'AssemblyLoadEventArgs', 'AssemblyLoadEventHandler',<br>
'AsyncCallback', 'Attribute', 'AttributeTargets',<br> 'AttributeUsageAttribute', 'BadImageFormatException',<br> 'Base64FormattingOptions', 'BitConverter', 'Boolean', 'Buffer',<br>
'Byte', 'CLSCompliantAttribute', 'CannotUnloadAppDomainException',<br> 'Char', 'CharEnumerator', 'CodeDom', 'Collections', 'Comparison',<br> 'ComponentModel', 'Configuration', 'Console',<br>
'ConsoleCancelEventArgs', 'ConsoleCancelEventHandler',<br> 'ConsoleColor', 'ConsoleKey', 'ConsoleKeyInfo',<br> 'ConsoleModifiers', 'ConsoleSpecialKey', 'ContextBoundObject',<br>
'ContextMarshalException', 'ContextStaticAttribute', 'Convert',<br> 'Converter', 'CrossAppDomainDelegate', 'DBNull',<br> 'DataMisalignedException', 'DateTime', 'DateTimeKind',<br>
'DateTimeOffset', 'DayOfWeek', 'Decimal', 'Delegate',<br> 'Deployment', 'Diagnostics', 'DivideByZeroException',<br> 'DllNotFoundException', 'Double', 'DuplicateWaitObjectException',<br>
'EntryPointNotFoundException', 'Enum', 'Environment',<br> 'EnvironmentVariableTarget', 'EventArgs', 'EventHandler',<br> 'Exception', 'ExecutionEngineException', 'FieldAccessException',<br>
'FileStyleUriParser', 'FlagsAttribute', 'FormatException',<br> 'FtpStyleUriParser', 'GC', 'GCCollectionMode', 'GenericUriParser',<br> 'GenericUriParserOptions', 'Globalization',<br>
'GopherStyleUriParser', 'Guid', 'HttpStyleUriParser',<br> 'IAppDomainSetup', 'IAsyncResult', 'ICloneable', 'IComparable',<br> 'IConvertible', 'ICustomFormatter', 'IDisposable', 'IEquatable',<br>
'IFormatProvider', 'IFormattable', 'IO', 'IServiceProvider',<br> 'IndexOutOfRangeException', 'InsufficientMemoryException',<br> 'Int16', 'Int32', 'Int64', 'IntPtr', 'InvalidCastException',<br>
'InvalidOperationException', 'InvalidProgramException',<br> 'LdapStyleUriParser', 'LoaderOptimization',<br> 'LoaderOptimizationAttribute', 'LocalDataStoreSlot',<br>
'MTAThreadAttribute', 'MarshalByRefObject', 'Math', 'Media',<br> 'MemberAccessException', 'MethodAccessException',<br> 'MidpointRounding', 'MissingFieldException',<br>
'MissingMemberException', 'MissingMethodException',<br> 'ModuleHandle', 'MulticastDelegate',<br> 'MulticastNotSupportedException', 'Net', 'NetPipeStyleUriParser',<br>
'NetTcpStyleUriParser', 'NewsStyleUriParser',<br> 'NonSerializedAttribute', 'NotFiniteNumberException',<br> 'NotImplementedException', 'NotSupportedException',<br>
'NullReferenceException', 'Nullable', 'Object',<br> 'ObjectDisposedException', 'ObsoleteAttribute', 'OperatingSystem',<br> 'OperationCanceledException', 'OutOfMemoryException',<br>
'OverflowException', 'ParamArrayAttribute', 'PlatformID',<br> 'PlatformNotSupportedException', 'Predicate', 'Random',<br> 'RankException', 'Reflection', 'ResolveEventArgs',<br>
'ResolveEventHandler', 'Resources', 'Runtime',<br> 'RuntimeArgumentHandle', 'RuntimeFieldHandle',<br> 'RuntimeMethodHandle', 'RuntimeTypeHandle', 'SByte',<br>
'STAThreadAttribute', 'Security', 'SerializableAttribute',<br> 'Single', 'StackOverflowException', 'String', 'StringComparer',<br> 'StringComparison', 'StringSplitOptions', 'SystemException',<br>
'Text', 'ThreadStaticAttribute', 'Threading', 'TimeSpan',<br> 'TimeZone', 'TimeoutException', 'Timers', 'Type', 'TypeCode',<br> 'TypeInitializationException', 'TypeLoadException',<br>
'TypeUnloadedException', 'TypedReference', 'UInt16', 'UInt32',<br> 'UInt64', 'UIntPtr', 'UnauthorizedAccessException',<br> 'UnhandledExceptionEventArgs', 'UnhandledExceptionEventHandler',<br>
'Uri', 'UriBuilder', 'UriComponents', 'UriFormat',<br> 'UriFormatException', 'UriHostNameType', 'UriIdnScope', 'UriKind',<br> 'UriParser', 'UriPartial', 'UriTypeConverter', 'ValueType',<br>
'Version', 'Void', 'WeakReference', 'Web', '_AppDomain',<br> '__builtins__', '__dict__', '__name__']<br><br> _______________________________________________<br>
Users mailing list<br></span></div> <a href="mailto:Users@lists.ironpython.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Users@lists.ironpython.com</a> <mailto:<a href="mailto:Users@lists.ironpython.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Users@lists.ironpython.com</a>><span class="q"><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><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> <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>