I am trying to update AppDomain.CurrentDomain after the domain is
started. Is AppDomainSetup the correct way to go? It seems this would
only apply at creation of the domain, and I need to make this
modification after the AppDomain has started.
I posted this to the Forums as well. I'm not clear whether the forums is
the right spot or here. They both seem to address the same issues.
Thanks
AppDomain.SetupInformation propetry is reference to an AppDomainSetup
object which you are free to modify, but this does not actually change
the underlying AppDomain's configuration. The way to change the
AppDomain's setup would be to create a new AppDomainSetup object and
assign that to the SetupInformation property of your AppDomain like
this:
AppDomain ad = AppDomain.CreateDomain("mydomain");
AppDomainSetup ads = new AppDomainSetup();
ads.PrivateBinPath = mynewpath;
ad.SetupInformation = ads; // <-- Won't compile because
SetupInformation is a readonly property
ad.SetupInformation.PrivateBinPath = mynewpath; // <-- Won't work
because the appdomain's SetupInformation is never actually changed
The right way to do this is to know what your PrivateBinPath will need
to be before setting up the domain and then have code that looks
something like this instead:
AppDomainSetup ads = new AppDomainSetup();
ads.PrivateBinPath = mybinpath;
AppDomain ad = AppDomain.CreateDomain(mydomainname, null, ads);
Console.WriteLine("PrivateBinPath: {0}",
ad.SetupInformation.PrivateBinPath);
The main reason for this change is that you should not be changing the
PrivateBinPath for an AppDomain once it has been created. It would
change the binding after Assemblies may have already been bound in that
AppDomain.