public static IApplicationHost Create(HostedAppInfo appInfo) { AppDomain domain = AppDomain.CreateDomain(appInfo.Name, null, new AppDomainSetup { ApplicationBase = AppDomain.CurrentDomain.BaseDirectory, PrivateBinPathProbe = null, DisallowApplicationBaseProbing = true, //TODO: use plugin app.config ConfigurationFile = AppDomain.CurrentDomain.SetupInformation.ConfigurationFile }); var appDomainInitializer = (AppDomainInitializer) domain.CreateInstanceFromAndUnwrap(typeof(AppDomainInitializer).Assembly.Location, typeof(AppDomainInitializer).FullName, false, BindingFlags.Default, null, null, null, null); appDomainInitializer.Initialize(appInfo.AssembliesToLoad, appInfo.NativeDllToLoad.ToArray()); var applicationHost = (ApplicationHost)domain.CreateInstanceFromAndUnwrap(typeof(ApplicationHost).Assembly.Location, typeof(ApplicationHost).FullName, false, BindingFlags.Default, null, null, null, null); return(new ApplicationHostProxy(applicationHost.load(appInfo), domain)); }
private IApplicationHost load(HostedAppInfo appInfo) { Type hostType = typeof(ApplicationHost <>).MakeGenericType(Type.GetType(appInfo.AppType)); return((IApplicationHost)Activator.CreateInstance(hostType, appInfo)); }
/// <summary> /// Extracted for testing purposes. /// </summary> internal virtual IApplicationHost CreateApplicationHost(HostedAppInfo appInfo) { return(ApplicationHost.Create(appInfo)); }