Question

I have a .NET application that is creating several separate AppDomains to run some plugginable code, each of the AppDomains sets up its own WCF named pipes service to communicate with the central application.

However I want to set a different working directory for each AppDomain, so that the base folder of any relative path is different in each app domain. So these plugins can create its own folder structure in all the normal file handling ways by going "./MyCustomFolder".

Unfortunately I am finding Directory.SetWorkingDirectory() is setting it for the whole process (not isolated to a single app domain) this is causing some plugins to write in other plugin directories.

Is it possible to change the working directory for different AppDomains, or do I need to kick off brand new processes to do what I'm after? If I need whole processes to do what Im after what is your opinions on trying to manage parent / child processes effectively in a stable way?

Was it helpful?

Solution

CurrentDirectory (or WorkingDirectory) is per process.

You can however setup assembly probing paths when creating the appdomain. Look at the AppDomainSetup class.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top