I'm receiving this error "Could not load file or assembly 'MyReferenceAssembly', Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified." when attempting to load a reference to another custom DLL.
AppDomainSetup domainSetup = new AppDomainSetup();
domainSetup.ApplicationBase = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
AppDomain domain = AppDomain.CreateDomain("myCustomDomain", null, domainSetup);
Type compilerType = typeof(MyCustomObject);
MyCustomObject cr = (MyCustomObject)domain.CreateInstanceFromAndUnwrap(compilerType.Assembly.Location, compilerType.FullName);
List<AssemblyName> references = compilerType.Assembly.GetReferencedAssemblies().ToList();
references.ForEach(r => domain.Load(r));
I have tried not loading the references but still encounter the same error. It does seem to successfully load any references that are in the GAC.
Do i need to load references into this domain? And if so, how do i load custom library references into a new AppDomain?