[IronPython] Application Domains and IronPython

Dino Viehland dinov at exchange.microsoft.com
Tue Apr 17 23:56:44 CEST 2007


For the call to .Load I think you'll want to provide "goodbye" instead of the fully qualified path.

If that still doesn't work there's a tool called fuslogvw.exe which is part of the .NET Framework SDK (on my machine it's in %ProgramFiles%\Microsoft Visual Studio 8\SDK\v2.0\Bin but if you don't have VS and instead just have the SDK I believe it ends up in %ProgramFiles%\Microsoft.NET\SDK\...).  Load that up, turn on the logging options, and then re-run.  Refresh in Fuslogvw and you'll see a list of places where it tried to load your assembly from and where it's not finding them.

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Michael Foord
Sent: Monday, April 16, 2007 3:12 PM
To: Discussion of IronPython
Subject: [IronPython] Application Domains and IronPython

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.CurrentDomain.SetupInformation.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
fails:

testClass = appDomain.CreateInstanceAndUnwrap(asmPath,
                                              "goodbye.GoodbyeWorld")

or:

appDomain.Load(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,


Fuzzyman
http://www.voidspace.org.uk/ironpython/index.shtml


_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com



More information about the Ironpython-users mailing list