Jump to content
Xtreme .Net Talk

Simple question - how to use AppDomainSetup.PrivateBinPath prop?(FW2.0)


Recommended Posts

Posted

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.

Posted
Have you tried

domSetup2.PrivateBinPath = IO.Path.Combine(Application.StartupPath, "P1");

instead of

domSetup2.PrivateBinPath = "P1";

 

I try - and no success. :o The same FileNotFoundException.... And besides, from MSDN:

AppDomainSetup.PrivateBinPath Property

Gets or sets the list of directories under the application base directory that are probed for private assemblies.

So, my guess, StartupPath added automatically by framework. In any case - any new ideas about "how to use PrivateBinPath correctly"?

  • *Experts*
Posted

I don't know much about loading a DLL into a different domain, but doing a Google on AppDomain Load FileNotFoundException produced a couple of articles that sound to me like you're not supposed to be trying what you're trying?

 

For example, from one article by Brad Adams, a Program Manager at MS:

AppDomain.Load() is only meant to be called on the current AppDomain (for use by Interop callers).

 

Sorry I'm not more help...

 

-nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted
For example' date=' from one article by Brad Adams, a Program Manager at MS:

-nerseus

 

Hmm... Sound reasonably. From MSDN:

AppDomain.Load Method (String)

public Assembly Load (

string assemblyString

)

.....

This method should only be used to load an assembly into the current application domain.

 

OK, but... does this mean that answer to question "how to load new assembly(.dll) into new domain if assembly(.dll) situated in sub-folder of app-main-folder" will be "impossible"?!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...