public static FluorineRuntimeProxy Start(HostManager hostManager, string physicalPath, string virtualPath, string privateBinPath, string configFile, string shadowCopyAssemblies, bool singleDomain) { if(!StringUtil.StringEndsWith(physicalPath, Path.DirectorySeparatorChar)) physicalPath = physicalPath + Path.DirectorySeparatorChar; // Copy this hosting DLL into the /bin directory of the application string fileName = Assembly.GetExecutingAssembly().Location; string binDirectory = Path.Combine(physicalPath, "Bin"); if (!Directory.Exists(binDirectory)) binDirectory = Path.Combine(physicalPath, "bin"); if (!Directory.Exists(binDirectory)) binDirectory = physicalPath; //Directory.CreateDirectory(binDirectory); try { string name = Path.GetFileName(fileName); File.Copy(fileName, Path.Combine(binDirectory, name), true); } catch{;} /* MakeShadowCopies(shadowCopyAssemblies, physicalPath); */ #if NET_2_0 TextWriter textWriter = new StreamWriter(Path.Combine(physicalPath, "web")); textWriter.Close(); string configurationFile = Path.Combine(physicalPath, "web"); System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(configurationFile); System.Net.Configuration.SettingsSection section = (System.Net.Configuration.SettingsSection)config.GetSection("system.net/settings"); section.Socket.AlwaysUseCompletionPortsForAccept = true; section.Socket.AlwaysUseCompletionPortsForConnect = true; config.Save(); #endif FluorineRuntimeProxy host = null; if (!singleDomain) host = ApplicationHost.CreateApplicationHost(typeof(FluorineRuntimeProxy), virtualPath, physicalPath, privateBinPath) as FluorineRuntimeProxy; else host = new FluorineRuntimeProxy(); if( host != null ) { host.HostManager = hostManager; host.VirtualPath = virtualPath; host.PhysicalDir = physicalPath; host.SingleDomain = singleDomain; host.BinDir = binDirectory; } if (singleDomain) { //AppDomain.CurrentDomain.AppendPrivatePath(binDirectory); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); } return host; }
private void OnAppDomainUnloadedCallback(object unused) { if (_hostManager != null) { _hostManager.OnAppDomainUnloaded(_applicationInfo, _reason); _hostManager = null; } }
public static FluorineRuntimeProxy Start(HostManager hostManager, string physicalPath, string virtualPath, string privateBinPath, string configFile, string shadowCopyAssemblies, bool singleDomain) { if (!StringUtil.StringEndsWith(physicalPath, Path.DirectorySeparatorChar)) { physicalPath = physicalPath + Path.DirectorySeparatorChar; } // Copy this hosting DLL into the /bin directory of the application string fileName = Assembly.GetExecutingAssembly().Location; string binDirectory = Path.Combine(physicalPath, "Bin"); if (!Directory.Exists(binDirectory)) { binDirectory = Path.Combine(physicalPath, "bin"); } if (!Directory.Exists(binDirectory)) { binDirectory = physicalPath; //Directory.CreateDirectory(binDirectory); } try { string name = Path.GetFileName(fileName); File.Copy(fileName, Path.Combine(binDirectory, name), true); } catch {; } /* * MakeShadowCopies(shadowCopyAssemblies, physicalPath); */ #if NET_2_0 TextWriter textWriter = new StreamWriter(Path.Combine(physicalPath, "web")); textWriter.Close(); string configurationFile = Path.Combine(physicalPath, "web"); System.Configuration.Configuration config = System.Configuration.ConfigurationManager.OpenExeConfiguration(configurationFile); System.Net.Configuration.SettingsSection section = (System.Net.Configuration.SettingsSection)config.GetSection("system.net/settings"); section.Socket.AlwaysUseCompletionPortsForAccept = true; section.Socket.AlwaysUseCompletionPortsForConnect = true; config.Save(); #endif FluorineRuntimeProxy host = null; if (!singleDomain) { host = ApplicationHost.CreateApplicationHost(typeof(FluorineRuntimeProxy), virtualPath, physicalPath, privateBinPath) as FluorineRuntimeProxy; } else { host = new FluorineRuntimeProxy(); } if (host != null) { host.HostManager = hostManager; host.VirtualPath = virtualPath; host.PhysicalDir = physicalPath; host.SingleDomain = singleDomain; host.BinDir = binDirectory; } if (singleDomain) { //AppDomain.CurrentDomain.AppendPrivatePath(binDirectory); AppDomain.CurrentDomain.AssemblyResolve += new ResolveEventHandler(CurrentDomain_AssemblyResolve); } return(host); }