[IronPython] Questions about compiled .py files - their stub exe and dlls

Michael Foord fuzzyman at voidspace.org.uk
Sat Dec 13 15:26:28 CET 2008

Guy Rozendorn wrote:
> Hi,
> I have a question about compiled python files with the pyc.py example.
> I read that the dll must exist from the directory from which the 
> executable is executed.
> For example, let's say I compiled my code to:
> myProg.exe
> myProgr.dll
> and they both reside in C:\Temp\myProg.exe, along with IronPython.dll 
> and IronPythonModules.dll

It looks like you are using the Pyc.py sample with IronPython 1. Can you 
update to IronPython 2 and try again.


Michael Foord

> If I try to execute myProg.exe from any other directory (i.e - I'm in 
> C:\Windows, and running C:\Temp\myProg.exe), I get the following error:
> Unhandled Exception: System.IO.FileNotFoundException: The system 
> cannot find the file specified. (Exception from HRESULT
> : 0x80070002)
>    at System.Reflection.Assembly.nLoadFile(String path, Evidence evidence)
>    at System.Reflection.Assembly.LoadFile(String path)
>    at PythonMain.Main()
> What do I need to do to make myProg.exe run from anywhere?
> Specfically, this bothers me because in deploying Windows Services 
> wriiten in IronPython.
> Let's say I just compiled myService.exe, along with myService.dll, and 
> they're both in C:\Temp (along with IronPython DLLs).
> After I register the service, it fails to start, since the current 
> directory of the services.exe (who executes myService.exe) is 
> %SystemRoot%\system32
> If I put myService.dll in the system32 directory, the service works.
> But I don't want to put myService.dll in system32 (and many more dlls 
> that I use).
> So, my question is:
> * Can I make the magic that will cause myService.exe/myProg.exe to 
> look for its DLL inside the directory in which he resides in (and not 
> the current directory)?
> * It is possible to include myService.dll and IronPython.dll and 
> IronPythonModules.dll inside myService.exe (so I could do import sys 
> and then append to path which ever directries I wish for)?
> Thanks,
> Guy
> ------------------------------------------------------------------------
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com


More information about the Ironpython-users mailing list