I managed to fix this with
AppDomain.CurrentDomain.AssemblyResolve
Question
I am trying to load assemblies into a new domain, However I Keep getting an error that the file specified cannot be found,
Note that I have a Directory Called 'Extensions' that contains a Folder 'Inspect' which contains a number of dll's
"System.IO.FileNotFoundException: Could not load file or assembly 'InspectBLL, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'" I am currently doing the following
public AppDomain GetAppDomain(DirectoryInfo dir, string domainName)
{
var assemblydll = dir.GetFiles().FirstOrDefault(x => x.Name.Contains("ServerDLL"));
AppDomainSetup domaininfo = new AppDomainSetup();
domaininfo.ApplicationBase = dir.FullName;
AppDomain domain = AppDomain.CreateDomain(domainName, null, domaininfo);
foreach (var item in dir.GetFiles())
{
var bytes = File.ReadAllBytes(item.FullName);
domain.Load(bytes);
}
return domain;
}
New Information that I Discovered, it seems that it is looking for the dll where the .exe is, which is bad. (I coppied the dlls to the exe all worked, however I need it to be in the Folder Extension\Inspect)
Solution
I managed to fix this with
AppDomain.CurrentDomain.AssemblyResolve