I have a class that utilizes a directory swap method for the Environment.CurrentDirectory. The code looks something like this:
var str = Environment.CurrentDirectory;
Environment.CurrentDirectory = Path.GetDirectoryName(pathToAssembly);
var assembly = Assembly.Load(Path.GetFileNameWithoutExtension(pathToAssembly));
Environment.CurrentDirectory = str;
As with my earlier post we are using this directory switching method to allow for loading of the specified assembly as well as any references assemblies, as well as unmanaged assemblies. The problem I am having is that this function is being run in two separate AppDomains. In AppDomain A (An AppDomain I create) the code works fine. In AppDomain B (the default AppDomain) it throws FileNotFoundException. For both of the calls I am trying to load the same assembly. Any clue why this would be the case?