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

Guy Rozendorn guy at rzn.co.il
Wed Dec 10 19:04:15 CET 2008


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

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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20081210/37d6301e/attachment.html>


More information about the Ironpython-users mailing list