Understanding AppDomainSetup.PrivateBinDir

  • Thread starter Thread starter Leo Tohill
  • Start date Start date
L

Leo Tohill

This code gives surprising results. At the end, "test1" is "test" and
"test2" is null

AppDomainSetup setup = AppDomain.CurrentDomain.SetupInformation;
setup.PrivateBinPath = "test";
AppDomain.CurrentDomain.SetupInformation.PrivateBinPath = "test";
string test1 = setup.PrivateBinPath;
string test2 = AppDomain.CurrentDomain.SetupInformation.PrivateBinPath;


My deeper problem is that I want to set the PrivateBinPath property of the
current
domain, and it won't set, as shown by this code, and evidenced by the fusion
log that I
look at after I get a failure from an assembly.Load().

How do I get PrivateBinPath to work? As recommended, I am specifying a
folder relative to
ApplicationBase, but I have also tried other variations.
 
Errata and notes:

1) I should have said "PrivateBinPath" instead of "PrivateBinDir"
2) I realize that the different results is because SetupInformation is a
value type (a struct, i guess)
Still, why is AppDomain.CurrentDomain.SetupInformation.PrivateBinPath
null after I set its value?

- leo
 
I think it may not be posible to change any of that on the 'current' domain.
You have one chance at some of the properties when the domain is being
loaded. after that , its not possible to change them. You may need to create
a new domain with the settings you need and use that.
 
sounds like a good theory.

Leo

William Wallace said:
I think it may not be posible to change any of that on the 'current'
domain.
You have one chance at some of the properties when the domain is being
loaded. after that , its not possible to change them. You may need to
create
a new domain with the settings you need and use that.
 
Try using the method AppDomain.CurrentDomain.AppendPrivateBinPath(path).
This takes a relative path and appends it to the list of paths for that
appdomain. You cannot set the property directly because it is not a simple
field you can get or set.
 
Back
Top