2

I want to use IronPython as a simple test harness for a .net application. I have created a project in Visual Studio 2008 and have an empty python source file. I have added my assemblies to the project in Visual Studio. I am familiar with general python programming.

How do I import and use classes from my referenced assemblies?

1 Answer 1

5

It should just be

import [namespace]

for common .NET libraries and namespaces, such as System

to use additional assemblies, first need to import clr then add a reference to additional assemblies

import clr
clr.AddReference("System.Xml")
from System.Xml import *

Take a look at

Also, have a look at where you installed IronPython. There is a lot of detail in the Tutorial.htm that can be found in \IronPython 2.0.1\Tutorial\Tutorial.htm

You generally create instance of classes like so

from System.Collections import *
# create an instance of Hashtable
h = Hashtable() 

from System.Collections.Generic import *
# create an instance of List<string>
l = List[str]()
Sign up to request clarification or add additional context in comments.

2 Comments

What about adding custom assemblies? I am having some trouble getting those to load.

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.