2 // System.Web.Hosting.ApplicationHost
5 // Patrik Torstensson (Patrik.Torstensson@labs2.com)
6 // (class signature from Bob Smith <bob@thestuff.net> (C) )
7 // Gonzalo Paniagua Javier (gonzalo@ximian.com)
10 using System.Collections;
12 using System.Runtime.Remoting;
14 namespace System.Web.Hosting
16 public sealed class ApplicationHost
18 class ConfigInitHelper
20 public void InitConfig ()
25 public static object CreateApplicationHost (Type hostType,
30 throw new ArgumentException ("hostType");
32 if (virtualDir == null || virtualDir.Length == 0)
33 throw new ArgumentException ("virtualDir");
35 if (physicalDir == null || physicalDir.Length == 0)
36 throw new ArgumentException ("physicalDir");
38 if (physicalDir [physicalDir.Length - 1] != Path.DirectorySeparatorChar)
39 physicalDir += Path.DirectorySeparatorChar;
41 int nowInt = DateTime.Now.ToString ().GetHashCode ();
42 string nowHash = nowInt.ToString ("x");
43 nowInt += physicalDir.GetHashCode ();
44 string sum = nowInt.ToString ("x");
45 Hashtable hTable = new Hashtable ();
46 AppDomainSetup domainSetup = new AppDomainSetup();
48 AppDomainFactory.PopulateDomainBindings (nowHash,
56 AppDomain domain = AppDomain.CreateDomain (nowHash, null, domainSetup);
57 foreach (string key in hTable.Keys)
58 domain.SetData (key, (string) hTable [key]);
60 domain.SetData (".hostingVirtualPath", virtualDir);
61 //domain.SetData(".hostingInstallDir", ?????);
62 InitConfigInNewAppDomain (domain);
63 ObjectHandle o = domain.CreateInstance (hostType.Assembly.FullName,
68 private static void InitConfigInNewAppDomain (AppDomain appDomain)
70 Type t = typeof (ConfigInitHelper);
71 ObjectHandle o = appDomain.CreateInstance (t.Assembly.FullName, t.FullName);
72 ConfigInitHelper helper = (ConfigInitHelper) o.Unwrap();