Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

AppDomain.AppendPrivatePath Depricated

86 views
Skip to first unread message

Jared Bienz

unread,
Sep 16, 2005, 1:36:32 AM9/16/05
to
I get a CS0618 that AppDomain.AppendPrivatePath is obsolete. The
suggestion is to use AppDomainSetup.PrivateBinPath instead, but no
matter how I set it, PrivateBinPath remains null.

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

Nick Hertl

unread,
Sep 16, 2005, 2:25:32 PM9/16/05
to
AppDomain.AppDomainSetup is a readonly property.
If you try to modify your AppDomain's SetupInformation property, the
change will disappear as fast as you make it, and here's why:

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.

0 new messages