Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
using System.EnterpriseServices.Internal;
public static void GacRegisterHost()
{
Publish pub = new Publish();
pub.GacInstall(AppDomain.CurrentDomain.BaseDirectory + @"\Mono.Security.dll");
pub.GacInstall(AppDomain.CurrentDomain.BaseDirectory + @"\Mono.Security.Win32.dll");
pub.GacInstall(AppDomain.CurrentDomain.BaseDirectory + @"\Mono.WebServer2.dll");
}
private static Host CreateWorkerAppDomainWithHost(string virtualPath, string physicalPath)
{
var hostType = typeof(Host);
// this creates worker app domain in a way that host doesn't need to be in GAC or bin
// using BuildManagerHost via private reflection
string uniqueAppString = string.Concat(virtualPath, physicalPath).ToLowerInvariant();
string appId = (uniqueAppString.GetHashCode()).ToString("x", CultureInfo.InvariantCulture);
// create BuildManagerHost in the worker app domain
var appManager = ApplicationManager.GetApplicationManager();
var buildManagerHostType = typeof (HttpRuntime).Assembly.GetType("System.Web.Compilation.BuildManagerHost");
var buildManagerHost = appManager.CreateObject(appId, buildManagerHostType, virtualPath, physicalPath, false);
// call BuildManagerHost.RegisterAssembly to make Host type loadable in the worker app domain
buildManagerHostType.InvokeMember(
"RegisterAssembly",
BindingFlags.Instance | BindingFlags.InvokeMethod | BindingFlags.NonPublic,
null,
buildManagerHost,
new object[2] {hostType.Assembly.FullName, hostType.Assembly.Location});
// create Host in the worker app domain
return (Host)appManager.CreateObject(appId, hostType, virtualPath, physicalPath, false);
}
Мой опыт работы с веб-сервером Cassini от Microsoft