protected void Autoload() { FileInfo fi = new System.IO.FileInfo(this.AssemblyFileLocation); AppDomainSetup setup = ReferenceAppDomain.AppDomainSetupAlt; ApplicationBase = fi.Directory.FullName; //System.AppDomain.CurrentDomain.BaseDirectory; setup.ShadowCopyFiles = "true"; setup.ApplicationBase = fi.Directory.FullName; if ((setup.PrivateBinPath != null) && !setup.PrivateBinPath.Contains(fi.Directory.FullName)) { setup.PrivateBinPath = string.Concat(setup.PrivateBinPath == null?"":setup.PrivateBinPath, fi.Directory.FullName, ";"); } ; // AppDomain separate = ReferenceAppDomain.CreateAppDomain( // ReferenceAppDomain.DefaultName,setup); // foreach (System.Reflection.Assembly asmb in separate.ReflectionOnlyGetAssemblies()) // { // Global.statG("asmb {0}",setup.PrivateBinPath); // Global.statG("asmb {0}",asmb.GetName()); // Global.statY("{0}",asmb.Location); // } try { Assembly = System.Reflection.Assembly.ReflectionOnlyLoadFrom(fi.FullName); } catch { } // separate.ActivationContext.(); // if (System.IO.File.Exists(AssemblyFileLocation)&& !(AssemblyIsLoaded)) // assembly = // separate.Load(fi.Name); // appBase = System.IO.Path.GetDirectoryName(Application.ExecutablePath); // to tell that it's loaded or not – for runtime (not xml serialization) if (fi.Extension == ".dll") { Context |= ReferenceAsmContextTypes.LoadedDll; } else if (fi.Extension == ".exe") { Context |= ReferenceAsmContextTypes.LoadedExe; } Name = Assembly.FullName.Split(',')[0]; }
public ReferenceAssemblyElement(FileInfo fi) // for xml serialization { Context = ReferenceAsmContextTypes.CurrentReflection; Assembly = Assembly.ReflectionOnlyLoadFrom(AssemblyFileLocation = fi.FullName); Autoload(); }