[IronPython] Importing System in IronPython 2 beta 5

Ronnie Maor ronnie.maor at gmail.com
Sun Sep 21 16:47:44 CEST 2008


I get the same problem.

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.

It fails with my hosting code, and also reproduces with the "hello world"
hosting sample:
http://blogs.msdn.com/seshadripv/archive/2008/09/11/dlr-hosting-sample-simple-dlr-host-using-the-new-app-config-based-scriptruntime-creation.aspx

The only changes I made to the sample were
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)
2) change the line defining the source code to:
            ScriptSource source =
pyEng.CreateScriptSourceFromString(@"import System",
SourceCodeKind.Statements);
3) remove the code that gets the "output" variable from pyEng (since we
don't produce it)

like I said, this fails with "No module named System".
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.

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...

thanks
Ronnie

On Sun, Sep 21, 2008 at 8:31 AM, Serge R <deus.verus at gmail.com> wrote:

> I am migrating from 1.1 and have been unable to import System.Math class. I
> took a look at what's actually been imported
>
> clr.AddReference("System")
> import System
> print dir(System)
>
> On IP2 I got a small list that didn't contain Math or many other classes.
> Am I referencing something wrong?
>
> IP2 List:
> ['CodeDom', 'Collections', 'ComponentModel', 'Configuration',
> 'Diagnostics', 'FileStyleUriParser', 'FtpStyleUriParser',
> 'GenericUriParser', 'GenericUriParserOptions', 'GopherStyleUriParser',
> 'HttpStyleUriParser', 'IO', 'LdapStyleUriParser', 'Media', 'Net',
> 'NetPipeStyleUriParser', 'NetTcpStyleUriParser', 'NewsStyleUriParser',
> 'Runtime', 'Security', 'Text', 'Threading', 'Timers', 'Uri', 'UriBuilder',
> 'UriComponents', 'UriFormat', 'UriFormatException', 'UriHostNameType',
> 'UriIdnScope', 'UriKind', 'UriParser', 'UriPartial', 'UriTypeConverter',
> 'Web']
>
> IP1 List:
> ['AccessViolationException', 'Action', 'ActivationContext', 'Activator',
> 'AppDomain', 'AppDomainInitializer', 'AppDomainManager',
> 'AppDomainManagerInitializationOptions', 'AppDomainSetup',
> 'AppDomainUnloadedException', 'ApplicationException', 'ApplicationId',
> 'ApplicationIdentity', 'ArgIterator', 'ArgumentException',
> 'ArgumentNullException', 'ArgumentOutOfRangeException',
> 'ArithmeticException', 'Array', 'ArraySegment',
> 'ArrayTypeMismatchException', 'AssemblyLoadEventArgs',
> 'AssemblyLoadEventHandler', 'AsyncCallback', 'Attribute',
> 'AttributeTargets', 'AttributeUsageAttribute', 'BadImageFormatException',
> 'Base64FormattingOptions', 'BitConverter', 'Boolean', 'Buffer', 'Byte',
> 'CLSCompliantAttribute', 'CannotUnloadAppDomainException', 'Char',
> 'CharEnumerator', 'CodeDom', 'Collections', 'Comparison', 'ComponentModel',
> 'Configuration', 'Console', 'ConsoleCancelEventArgs',
> 'ConsoleCancelEventHandler', 'ConsoleColor', 'ConsoleKey', 'ConsoleKeyInfo',
> 'ConsoleModifiers', 'ConsoleSpecialKey', 'ContextBoundObject',
> 'ContextMarshalException', 'ContextStaticAttribute', 'Convert', 'Converter',
> 'CrossAppDomainDelegate', 'DBNull', 'DataMisalignedException', 'DateTime',
> 'DateTimeKind', 'DateTimeOffset', 'DayOfWeek', 'Decimal', 'Delegate',
> 'Deployment', 'Diagnostics', 'DivideByZeroException',
> 'DllNotFoundException', 'Double', 'DuplicateWaitObjectException',
> 'EntryPointNotFoundException', 'Enum', 'Environment',
> 'EnvironmentVariableTarget', 'EventArgs', 'EventHandler', 'Exception',
> 'ExecutionEngineException', 'FieldAccessException', 'FileStyleUriParser',
> 'FlagsAttribute', 'FormatException', 'FtpStyleUriParser', 'GC',
> 'GCCollectionMode', 'GenericUriParser', 'GenericUriParserOptions',
> 'Globalization', 'GopherStyleUriParser', 'Guid', 'HttpStyleUriParser',
> 'IAppDomainSetup', 'IAsyncResult', 'ICloneable', 'IComparable',
> 'IConvertible', 'ICustomFormatter', 'IDisposable', 'IEquatable',
> 'IFormatProvider', 'IFormattable', 'IO', 'IServiceProvider',
> 'IndexOutOfRangeException', 'InsufficientMemoryException', 'Int16', 'Int32',
> 'Int64', 'IntPtr', 'InvalidCastException', 'InvalidOperationException',
> 'InvalidProgramException', 'LdapStyleUriParser', 'LoaderOptimization',
> 'LoaderOptimizationAttribute', 'LocalDataStoreSlot', 'MTAThreadAttribute',
> 'MarshalByRefObject', 'Math', 'Media', 'MemberAccessException',
> 'MethodAccessException', 'MidpointRounding', 'MissingFieldException',
> 'MissingMemberException', 'MissingMethodException', 'ModuleHandle',
> 'MulticastDelegate', 'MulticastNotSupportedException', 'Net',
> 'NetPipeStyleUriParser', 'NetTcpStyleUriParser', 'NewsStyleUriParser',
> 'NonSerializedAttribute', 'NotFiniteNumberException',
> 'NotImplementedException', 'NotSupportedException',
> 'NullReferenceException', 'Nullable', 'Object', 'ObjectDisposedException',
> 'ObsoleteAttribute', 'OperatingSystem', 'OperationCanceledException',
> 'OutOfMemoryException', 'OverflowException', 'ParamArrayAttribute',
> 'PlatformID', 'PlatformNotSupportedException', 'Predicate', 'Random',
> 'RankException', 'Reflection', 'ResolveEventArgs', 'ResolveEventHandler',
> 'Resources', 'Runtime', 'RuntimeArgumentHandle', 'RuntimeFieldHandle',
> 'RuntimeMethodHandle', 'RuntimeTypeHandle', 'SByte', 'STAThreadAttribute',
> 'Security', 'SerializableAttribute', 'Single', 'StackOverflowException',
> 'String', 'StringComparer', 'StringComparison', 'StringSplitOptions',
> 'SystemException', 'Text', 'ThreadStaticAttribute', 'Threading', 'TimeSpan',
> 'TimeZone', 'TimeoutException', 'Timers', 'Type', 'TypeCode',
> 'TypeInitializationException', 'TypeLoadException', 'TypeUnloadedException',
> 'TypedReference', 'UInt16', 'UInt32', 'UInt64', 'UIntPtr',
> 'UnauthorizedAccessException', 'UnhandledExceptionEventArgs',
> 'UnhandledExceptionEventHandler', 'Uri', 'UriBuilder', 'UriComponents',
> 'UriFormat', 'UriFormatException', 'UriHostNameType', 'UriIdnScope',
> 'UriKind', 'UriParser', 'UriPartial', 'UriTypeConverter', 'ValueType',
> 'Version', 'Void', 'WeakReference', 'Web', '_AppDomain', '__builtins__',
> '__dict__', '__name__']
>
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20080921/342da90c/attachment.html>


More information about the Ironpython-users mailing list