Simple question - how to use AppDomainSetup.PrivateBin prop?

  • Thread starter Thread starter Sneil
  • Start date Start date
S

Sneil

Situation: I have non-strong-name library _1Lib_.dll and want to load
it in new domain. Startup app - just console app with code:

using System;
using System.Reflection;

namespace _1Main_
{
class Program
{
static void Main(string[] args)
{
AppDomainSetup domSetup2 = new AppDomainSetup();
domSetup2.ApplicationBase =
AppDomain.CurrentDomain.BaseDirectory;
domSetup2.PrivateBinPath = "P1";
AppDomain anotherAD2 =
AppDomain.CreateDomain("SecondAppDomain", null, domSetup2);
anotherAD2.Load("_1Lib_");

Console.ReadKey();
}
}
}

And how folders organized:
c:\MyDir\_1Main_.exe << Startup app
c:\MyDir\P1\_1Lib_.dll << Lib I want to load

But code above just thow System.IO.FileNotFoundException crossed an
AppDomain boundary. Message of exception: "Could not load file or
assembly '_1Lib_, Version=1.0.0.0, Culture=neutral,
PublicKeyToken=null' or one of its dependencies." But if I move
_1Lib_.dll to the c:\MyDir\ (so both _1Main_.exe and _1Lib_.dll appear
in the same folder) code work just fine. But I really need to place lib
in SUB-folder of MainApp-folder!! Help!!

Thanks.
 
Please remove Console.ReadKey() and compile. As you mentioned, the
library is not strong named. Based on yor statement, there will not be a
key file existing which would result in a FileNotFound exception.

Thanks and Regards,
Daniel
 
William said:
Please remove Console.ReadKey() and compile. As you mentioned, the
library is not strong named. Based on yor statement, there will not
be a key file existing which would result in a FileNotFound exception.

Thanks and Regards,
Daniel

Thanks for reply! Yes, I did it - remove Console.ReadKey() and compile.
No luck - the same FileNotFound exception. :( OK, I ask more general
question.

1. In c:\MyApp we have MyApp.exe - assembly that represent our
application
2. In c:\MyApp\MyLib we have MyLib.dll - assembly that MyApp.exe needed
to work
3. MyApp.exe want to load MyLib.dll _in new domain_(!important!).
4. How?
 
Back
Top