System.Threading is actually in mscorlib, so you'd have to
AddReference("mscorlib") as well. Alternatively, you can load both mscorlib
and System.dll in your hosting code by saying something like this:

ScriptDomainManager.CurrentManager.LoadAssembly(typeof(string).Assembly);
//mscorlib.dll
ScriptDomainManager.CurrentManager.LoadAssembly(typeof(System.Diagnostics.Debug).Assembly);
//System.dll

I think we've changed this in 2.6A1 so that these are always loaded by
default in hosting scenarios.

On Wed, May 6, 2009 at 8:51 PM, Douglas Blank <[email protected]> wrote:

> I'm working on a couple of variations of an IronPython Shell, and I have
> the following issue. When I import some DLLs interactively, I'm not seeing
> all of the available objects. For example, in my shells I try:
>
> >>> import clr
> >>> clr.AddReference("System")
> >>> from System.Threading import Thread
>
> and I get the error that 'Cannot import name Thread'. In fact, if I:
>
> >>> import System.Threading
> >>> dir(System.Threading)
>
> I get:
>
> ['Semaphore', 'SemaphoreFullException', 'ThreadExceptionEventArgs',
> 'ThreadExceptionEventHandler']
>
> However, using the ipy.exe console, I correctly get:
>
> >>> import System.Threading
> >>> dir(System.Threading)
> ['AbandonedMutexException', 'ApartmentState', 'AsyncFlowControl',
> 'AutoResetEvent', 'CompressedStack', 'ContextCallback', 'EventResetMode',
> 'EventWaitHandle', 'ExecutionContext', 'HostExecutionContext',
> 'HostExecutionContextManager', 'IOCompletionCallback', 'Interlocked',
> 'LockCookie', 'ManualResetEvent', 'Monitor', 'Mutex', 'NativeOverlapped',
> 'Overlapped', 'ParameterizedThreadStart', 'ReaderWriterLock',
> 'RegisteredWaitHandle', 'Semaphore', 'SemaphoreFullException', 'SendOrP
> ostCallback', 'SynchronizationContext', 'SynchronizationLockException',
> 'Thread', 'ThreadAbortException', 'ThreadExceptionEventArgs',
> 'ThreadExceptionEventHandler', 'ThreadInterruptedException', 'ThreadPool',
> 'ThreadPriority', 'ThreadStart', 'ThreadStartException', 'ThreadState',
> 'ThreadStateException', 'Timeout', 'Timer', 'TimerCallback',
> 'WaitCallback', 'WaitHandle', 'WaitHandleCannotBeOpenedException',
> 'WaitOrTimerCallback']
>
> I feel I must be doing something fundamentally wrong... anyone have a
> guess as to what that might be? Thanks for any ideas!
>
> -Doug
>
> _______________________________________________
> Users mailing list
> [email protected]
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to