[IronPython] Application Domains and IronPython

Michael Foord fuzzyman at voidspace.org.uk
Tue Apr 17 00:11:46 CEST 2007

Hello all,

I'm trying to experiment with using AppDomains from IronPython - and not 
getting very far.

I've created a simple assembly in C#, containing the following :

using System;
namespace goodbye
public class GoodbyeWorld

public void test()

Console.WriteLine("Goodbye World!");

This is saved as 'goodbye.dll' and I can use it fine from IronPython.

The initial code to create the AppDomain is as follows:

import clr

from System import AppDomain, AppDomainSetup, MarshalByRefObject
from System.Environment import CurrentDirectory
from System.IO import Path, Directory
from System.Reflection import Assembly

ads = AppDomainSetup()
ads.ApplicationBase = Directory.GetCurrentDirectory()
ads.DisallowBindingRedirects = False
ads.DisallowCodeDownload = True
ads.ConfigurationFile = 

appDomain = AppDomain.CreateDomain("newAppDomain", None, ads)

asmPath =  Path.Combine(Directory.GetCurrentDirectory(), "goodbye.dll")

So far so good.

If I try *either* of the following lines to *use* the appdomain, then it 

testClass = appDomain.CreateInstanceAndUnwrap(asmPath,



The error is:

Traceback (most recent call last):
  File C:\Python Projects\modules in progress\ironpython\appDomain.py, 
line 22,
in Initialize
  File , line 0, in Load##97
  File mscorlib, line unknown, in Load
IOError: Could not load file or assembly 'C:\\Python Projects\\modules 
in progre
ss\\ironpython\\goodbye.dll' or one of its dependencies. The given 
assembly name
 or codebase was invalid. (Exception from HRESULT: 0x80131047)

I've also tried loading the assembly and using the assembly name, which 
is obviously wrong because it then fails to find the assembly.

Anyone got any clues as to what I am doing wrong ?

All the best,


More information about the Ironpython-users mailing list