[IronPython] Uninformative Type Error

Bakalar, Matthew (NIH/CIT) [C] bakalarmh at mail.nih.gov
Tue Jun 1 21:34:39 CEST 2010


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:dinov at microsoft.com]
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: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20100601/cb9e58c5/attachment.html>


More information about the Ironpython-users mailing list