[IronPython] Uninformative Type Error

Dino Viehland dinov at microsoft.com
Tue Jun 1 19:41:23 CEST 2010


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/32d48f74/attachment.html>


More information about the Ironpython-users mailing list