Thank you very much Dino, I added the folders that contain my assemblies to 
sys.path and then used clr.AddReference to add a reference to them. The type 
error no longer exists.
Matt Bakalar


From: Dino Viehland [mailto:[email protected]]
Sent: Tuesday, June 01, 2010 1:41 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Uninformative Type Error

This is caused by having the same assembly loaded into 2 different loader 
contexts at once (loader contexts are a part of the CLR loading 
infrastructure).  Adding references to assemblies by file can be tricky.  One 
possible solution might be to install both assemblies into the GAC and then do 
clr.AddReference.  Another might be to make sure they're next to ipy.exe (or 
whatever the host process is if it's not ipy.exe) and then also do a 
clr.AddReference.  You could also attempt to debug where the assemblies are 
getting loaded and try to make the add reference to file work - that would 
involve using fuslogvw.exe (logging all loads) and probably looking at 
PythonContext.TryLoadAssemblyFromFileWithPath.  But the other choices are 
probably much easier and more robust.

From: [email protected] 
[mailto:[email protected]] On Behalf Of Bakalar, Matthew 
(NIH/CIT) [C]
Sent: Tuesday, June 01, 2010 7:15 AM
To: Discussion of IronPython
Subject: [IronPython] Uninformative Type Error

Hello All,
I am running into a frustrating exception. When attempting to instantiate a 
class with an argument that is an instance of a different class from a separate 
assembly, I receive an unhelpful type error from the IronPython interpreter:
TypeError: expected XYZPositioner, got XYZPositioner
Both assemblies were loaded using clr.AddReferenceToFileAndPath. I have tried 
to confirm the type of the object I am passing as an argument to the 
constructor:
> A.GetType() == Target.Devices.XYZPositioner
True
Is there any way to get more information about the error? (The message reminds 
me of my days working in OCaml, where all of the error messages were translated 
from French grammar and it was never clear how to differentiate the object from 
the subject)
Thanks,
Matt Bakalar
_______________________________________________
Users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to