1

In IronPython 2.7.1, I can import some .NET assemblies by name:

>>> from System.Collections import *
>>> from System.IO import *

Others give me an error:

>>> from System.Xml import *
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: No module named Xml

Doing the following fixes the error:

>>> import clr
>>> clr.AddReferenceByPartialName('System.Xml')
>>> from System.Xml import *

Why do I have to call clr.AddReferenceByPartialName for some assemblies but not others?

1 Answer 1

3

Some assemblies, like mscorlib.dll, are there by default. If the documentation for the class you want says it's in mscorlib (e.g., http://msdn.microsoft.com/en-us/library/system.collections.arraylist.aspx), then you won't need to add a reference, otherwise you will. It's similar to when/why you need to add references to your C# project.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.