[IronPython] COM Object Issue

Zaur Shibzoukhov szport at gmail.com
Thu Dec 11 09:16:23 CET 2008


I just discovered strange thing with COM (IP 2.0):

D:\Downloads\IronPython-2.0-Bin\IronPython-2.0>ipy.exe
-X:ExceptionDetail -X:ShowClrExceptions
IronPython 2.0 (2.0.0.0) on .NET 2.0.50727.1433
Type "help", "copyright", "credits" or "license" for more information.
>>> import System
>>> wt=System.Type.GetTypeFromProgID("Word.Application")
>>> wa=System.Activator.CreateInstance(wt)
>>> wa.Documents.Add()
<Microsoft.Office.Interop.Word.DocumentClass (_Document) object at
0x000000000000002B>
>>> wa.Documents[1]
Error while invoking Item.
   в Microsoft.Scripting.Com.ComRuntimeHelpers.CheckThrowException(Int32
hresult, ExcepInfo& excepInfo, UInt32 argErr, String message)
   в _stub_$26##25(Closure , CallSite , DispCallable )
   в Microsoft.Scripting.Actions.MatchCaller.Call1[T0,TRet](Func`3
target, CallSite site, Object[] args)
   в Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args)
   в Microsoft.Scripting.Actions.UpdateDelegates.Update1[T,T0,TRet](CallSite
site, T0 arg0)
   в _stub_$25##24(Closure , CallSite , ComObject , Int32 )
   в Microsoft.Scripting.Actions.MatchCaller.Call2[T0,T1,TRet](Func`4
target, CallSite site, Object[] args)
   в Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args)
   в Microsoft.Scripting.Actions.UpdateDelegates.Update2[T,T0,T1,TRet](CallSite
site, T0 arg0, T1 arg1)
   в _stub_$24##23(Closure , CallSite , Object , Int32 )
   в Microsoft.Scripting.Actions.MatchCaller.Call2[T0,T1,TRet](Func`4
target, CallSite site, Object[] args)
   в Microsoft.Scripting.Actions.CallSite`1.UpdateAndExecute(Object[] args)
   в Microsoft.Scripting.Actions.UpdateDelegates.Update2[T,T0,T1,TRet](CallSite
site, T0 arg0, T1 arg1)
   в <module>$23##22(Closure , Scope , LanguageContext )
   в Microsoft.Scripting.Runtime.OptimizedScriptCode.InvokeTarget(LambdaExpression
code, Scope scope)
   в Microsoft.Scripting.ScriptCode.Run(Scope scope)
   в IronPython.Hosting.PythonCommandLine.<>c__DisplayClass1.<RunOneInteraction>b__0()
StandardError: Error while invoking Item.
CLR Exception:
    TargetParameterCountException
:
Error while invoking Item.
>>> wa.Documents[None,1]
<Microsoft.Office.Interop.Word.DocumentClass (_Document) object at
0x000000000000002B>
>>> wa.Documents[100000000000000000000,1]
<Microsoft.Office.Interop.Word.DocumentClass (_Document) object at
0x000000000000002B>

It looks like IP's wa.Documents indexer make wrong call of .Item.

-- Zaur


More information about the Ironpython-users mailing list