The behavior currently depends on whether or not the RCW gets strongly-typed 
when it enters the managed world. As a workaround, the following registry 
script Misha provided could "fix" your machine by registering the PIA:

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32]
"Assembly"="Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, 
PublicKeyToken=71E9BCE111E9429C"
"Class"="Microsoft.Office.Interop.Excel.ApplicationClass"
"RuntimeVersion"="v1.1.4322"

[HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32\12.0.0.0]
"Assembly"="Microsoft.Office.Interop.Excel, Version=12.0.0.0, Culture=neutral, 
PublicKeyToken=71E9BCE111E9429C"
"Class"="Microsoft.Office.Interop.Excel.ApplicationClass"
"RuntimeVersion"="v1.1.4322"

Your script should work independent of whether the PIA is registered or not. We 
will look into it and see what is going.

The implementation of -X:PreferComDispatch is still not complete. We are 
working on improving it and will enable it by default once all issues are 
flushed out. You are on the cutting edge and providing us with advance feedback 
:)

-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of nekomaho
Sent: Thursday, November 15, 2007 4:45 AM
To: Discussion of IronPython
Subject: Re: [IronPython] AttributeError: '__ComObject' object has no attribute 
'Visible'

Hi,

I use Windows XP Pro SP2 ja & Office 2007 Pro ja.

IronPython-2.0A6>ipy.exe -X:PreferComDispatch -X:TabCompletion 
-X:ExceptionDetail
IronPython console: IronPython 2.0A6 (2.0.11102.00) on .NET 2.0.50727.832
Copyright (c) Microsoft Corporation. All rights reserved.
>>> import clr
>>> from System import Type, Activator
>>> t = Type.GetTypeFromProgID('Excel.Application')
>>> e = Activator.CreateInstance(t)
>>> e.Visible = True
'__ComObject' object has no attribute 'Visible'
   場所 Microsoft.Scripting.Ast.ThrowStatement.DoExecute(CodeContext context)
   場所 Microsoft.Scripting.Ast.Statement.Execute(CodeContext context)
   場所 
Microsoft.Scripting.Actions.ActionBinder.UpdateSiteAndExecute[T](CodeContext 
callerContext, DynamicAction action, Object[] args, Object site, T& target, 
RuleSet`1& rules)
   場所 
Microsoft.Scripting.Actions.DynamicSite`3.UpdateBindingAndInvoke(CodeContext 
context, T0 arg0, T1 arg1)
   場所 
Microsoft.Scripting.Actions.DynamicSiteHelpers.UninitializedTargetHelper`7.Invoke2(DynamicSite`3
 site, CodeContext context, T0 arg0, T1 arg1)
   場所 Microsoft.Scripting.Actions.DynamicSite`3.Invoke(CodeContext context, T0 
arg0, T1 arg1)
   場所 ##29(Object[] , CodeContext )
   場所 Microsoft.Scripting.ScriptCode.Run(CodeContext codeContext, Boolean 
tryEvaluate)
   場所 Microsoft.Scripting.ScriptCode.Run(ScriptModule module)
   場所 Microsoft.Scripting.Hosting.CompiledCode.Evaluate(IScriptModule module)
   場所 Microsoft.Scripting.Hosting.ScriptEngine.ExecuteCommand(String code, 
IScriptModule module)
   場所 Microsoft.Scripting.Shell.CommandLine.RunOneInteraction()
   場所 Microsoft.Scripting.Shell.CommandLine.TryInteractiveAction()
   場所 IronPython.Hosting.PythonCommandLine.TryInteractiveAction()
   場所 Microsoft.Scripting.Shell.CommandLine.RunInteractiveLoop()
AttributeError: '__ComObject' object has no attribute 'Visible'

Thanks

> This works for me as well.  Could you please re-run your code snippet under 
> the -X:ExceptionDetail mode and send us the output?  Also, what versions of 
> Windows and Office are being used?
>
> Thanks
>
> From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Mohammad 
> Tayseer
> Sent: Wednesday, November 14, 2007 8:02 AM
> To: Discussion of IronPython
> Subject: Re: [IronPython] AttributeError: '__ComObject' object has no 
> attribute 'Visible'
>
> It works for me. What version of Excel do you use??
>
> Mohammad Tayseer
> http://spellcoder.com/blogs/tayseer
>
> ----- Original Message ----
> From: nekomaho <[EMAIL PROTECTED]>
>
>
> Hi,
>
> I get AttributeError in IronPython 2.0A6 & A5, but 2.0A4 is ok. why?
>
>
> ________________________________
> Be a better pen pal. Text or chat with friends inside Yahoo! Mail. See 
> how.<http://us.rd.yahoo.com/evt=51732/*http:/overview.mail.yahoo.com/>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> Users@lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
_______________________________________________
Users mailing list
Users@lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to