IronPython

Coordinator
Feb 8, 2016 at 5:30 PM
I'm trying to run the following ESAPI script under IronPython:
import sys
import clr
import System

# Add Varian's path when referencing assemblies
sys.path.append(r"C:\Program Files (x86)\Varian\Vision\13.6\Bin64")

# Reference the Varian API assemblies
clr.AddReferenceToFile(r"VMS.TPS.Common.Model.API.dll")
clr.AddReferenceToFile(r"VMS.TPS.Common.Model.Types.dll")

from System.Threading import *
from VMS.TPS.Common.Model.API import *
from VMS.TPS.Common.Model.Types import *

def main():
    with Application.CreateApplication("SysAdmin", "SysAdmin") as app:
        pass

# Run main() in an STA thread (required by ESAPI)
t = Thread(ThreadStart(main))
t.ApartmentState = ApartmentState.STA
t.Start()
It doesn't do anything, other than try to create an Eclipse application object, but it's unable to load some dependent assemblies:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'VMS.TPS.Common.Model.Interface, Version=13.6.30.20230, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
Any ideas? Thanks!
Coordinator
Feb 9, 2016 at 2:38 PM
I got it to work by removing the threading code. The following script works:
import sys
import clr
import System

# Add Varian's path when referencing assemblies
sys.path.append(r"C:\Program Files (x86)\Varian\Vision\13.6\Bin64")

# Reference the Varian API assemblies
clr.AddReferenceToFile("VMS.TPS.Common.Model.API.dll")
clr.AddReferenceToFile("VMS.TPS.Common.Model.Types.dll")

from System.Threading import *
from VMS.TPS.Common.Model.API import *
from VMS.TPS.Common.Model.Types import *

with Application.CreateApplication("SysAdmin", "SysAdmin") as app:
    for ps in app.PatientSummaries:
        print ps.Id