[Mono-dev] Assembly.Load fails when specifying multiple directoriesin AppDomainSetup.PrivateBinPath

Gert Driesen gert.driesen at telenet.be
Thu Apr 19 05:27:32 EDT 2007


Lionel,
 
You must use Path.PathSeparator (which will get you ';' on Windows, and ':'
on unix) instead of ';' to separate both directories.
 
When you're constructing the privatebinpath from code this will work fine,
but problem is when you're configuring it from an application configuration
file. In that case, you'll need separate configuration files for each
platform.
 
Gert

  _____  

From: mono-devel-list-bounces at lists.ximian.com
[mailto:mono-devel-list-bounces at lists.ximian.com] On Behalf Of Lionel Cuir
Sent: donderdag 19 april 2007 11:23
To: mono-devel-list at ximian.com
Subject: [Mono-dev] Assembly.Load fails when specifying multiple
directoriesin AppDomainSetup.PrivateBinPath


When I create an AppDomain by specifying a single subdirectory in the
AppDomainSetup.PrivateBinPath, an Assembly.Load works well in both Mono and
.Net and is able to load any assembly located in that directory. But if I'm
specifying two subdirectories, Mono will fail loading any assembly from any
of these two subdirectories, while .Net will succeed (with the same code -
see below).

Can anybody tell me if I'm doing things correctly? If that's a bug in Mono,
could you tell me to which file I should look at so that I can try to patch
the problem?

Regards,
Lionel

////////////////////////////////////////

To reproduce the problem:

1. Use the code below to create a main application and compile it into
/home/myapp for instance.


using System;
using System.Reflection;

class MainClass : MarshalByRefObject
{
    static int Main()
    {
        AppDomainSetup domainSetup = new AppDomainSetup();
        domainSetup.ApplicationBase = AppDomain.CurrentDomain.BaseDirectory;
        domainSetup.ConfigurationFile =
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile;
        domainSetup.PrivateBinPath = "solution";
        AppDomain _secondaryDomain =
AppDomain.CreateDomain("SecondaryDomain", AppDomain.CurrentDomain.Evidence,
domainSetup);

        MainClass _secondDomainHost =
(MainClass)_secondaryDomain.CreateInstanceFromAndUnwrap(
            typeof(MainClass).Assembly.Location,
typeof(MainClass).FullName);
        _secondDomainHost.Run();

        Console.WriteLine("Press a key to continue...");
        Console.ReadKey();
        return 0;
    }

    void Run()
    {
        Assembly ass = Assembly.Load("test");

        Console.WriteLine("Loaded:");
        Console.WriteLine(ass.FullName);
        Console.WriteLine("from: " + ass.Location);
    }
}



2. Create the directory /home/myapp/solution

3. Use the code below to create the assembly test.dll and compile it into
/home/myapp/solution


using System;

namespace Test
{
    public class TestClass
    {
    }
}



4. Run the main app -> it works

5. Now create the directory  /home/myapp/function and change the main
application 's AppDomainSetup.PrivateBinPath statement into:

        domainSetup.PrivateBinPath = "solution;function";   // This does not
work with Mono
        // domainSetup.PrivateBinPath = "solution";   // Old line - it was
working

==> Now, Assembly.Load throws an exception: 


 System.IO.FileNotFoundException: Could not load file or assembly 'test' or
one of its dependencies. The system cannot find the file specified.
File name: 'test'
  at (wrapper xdomain-invoke) MainClass:Run (string[])
  at (wrapper remoting-invoke-with-check) MainClass:Run (string[])
  at MainClass.Main (System.String[] args) [0x00000]



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-devel-list/attachments/20070419/a8f474d7/attachment.html 


More information about the Mono-devel-list mailing list