static void Load() { if (AppDomain.CurrentDomain.FriendlyName != "OnlineVideosSiteUtilDlls") { if (_useSeperateDomain) { _domain = AppDomain.CreateDomain("OnlineVideosSiteUtilDlls", null, null, null, true); // we need to subscribe to AssemblyResolve on the MP2 AppDomain because OnlineVideos.dll is loaded in the LoadFrom Context // and when unwrapping transparent proxy from our AppDomain, resolving types will fail because it looks only in the default Load context // we simply help .Net by returning the already loaded assembly from the LoadFrom context AppDomain.CurrentDomain.AssemblyResolve += AssemblyResolve; _pluginLoader = (PluginLoader)_domain.CreateInstanceFromAndUnwrap( Assembly.GetExecutingAssembly().Location, typeof(PluginLoader).FullName); AppDomain.CurrentDomain.AssemblyResolve -= AssemblyResolve; _domain.SetData(typeof(PluginLoader).FullName, _pluginLoader); } else { _domain = AppDomain.CurrentDomain; _pluginLoader = new PluginLoader(); } } else { _domain = AppDomain.CurrentDomain; _pluginLoader = (PluginLoader)AppDomain.CurrentDomain.GetData(typeof(PluginLoader).FullName); } }
internal static void Reload() { List<object> singletonNames = AppDomain.CurrentDomain.GetData("Singletons") as List<object>; AppDomain.Unload(_domain); _domain = null; _pluginLoader = null; if (singletonNames != null) foreach (var s in singletonNames) s.GetType().InvokeMember("_Instance", BindingFlags.Static | BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.SetField, null, s, new object[] { null }); Load(); }