[IronPython] Program.py can't find its DLL when compiled with pyc.py

Brian Wilson brian at wildsong.biz
Mon Jun 13 17:13:18 PDT 2011


Can anyone shed any light on this? I spent several hours searching the
Web for some hints with no luck.

Using VS2010, I built a little IronPython program and added a Windows
form to it as a separate project.
It all works fine when invoked as "ipyw.exe -D Program.py".
(IronPython 2.6.2 with .net 2.0)

Moving on to try out pyc.py, I built a trivial program (no separate
form) and the executable works fine.
(I used the sample that gets created when you create a new IP project
in VS2010.)

But when I try to build and run my version with the separate form, it
does not work; my compiled python can't find the DLL when run.
The exact error message is this:

Unhandled Exception: System.IO.IOException: Could not add reference to
assembly form.dll
   at Microsoft.Scripting.Actions.Calls.MethodCandidate.Caller.Call(Object[]
args, Boolean& shouldOptimize)
   at IronPython.Runtime.Types.BuiltinFunction.BuiltinFunctionCaller`6.Call5(CallSite
site, CodeContext context, TFuncType func, T0 arg0, T1 arg1, T2 arg2,
T3 arg3, T4 arg4)
   at System.Dynamic.UpdateDelegates.UpdateAndExecute7[T0,T1,T2,T3,T4,T5,T6,TRet](CallSite
site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6)
   at IronPython.Runtime.Importer.Import(CodeContext context, String
fullName, PythonTuple from, Int32 level)
   at IronPython.Runtime.Operations.PythonOps.InitializeModule(Assembly
precompiled, String main, String[] references)
   at PythonMain.Main()

The pyc.py build command is

  ipy.exe pyc.py /main:Program.py /out:setup /target:winexe

I am building and running in a directory containing the DLL's,

form.dll
IronPython.Modules.dll
IronPython.dll
Lib
Microsoft.Dynamic.dll
Microsoft.Scripting.Core.dll
Microsoft.Scripting.ExtensionAttribute.dll
Microsoft.Scripting.dll
Program.py
pyc.py

Here is my Program.py

import clr
clr.AddReference('System.Windows.Forms')
from System.Windows.Forms import *
clr.AddReference('form.dll')
from ipform import Form1
form = Form1()
Application.Run(form)

-- 
Brian Wilson
Corvallis Oregon


More information about the Users mailing list