/// <summary> /// Initializes a new instance of the <see cref="T:Ceen.Httpd.Cli.Runner.AppDomainWrapper"/> class. /// </summary> /// <param name="domain">The domain to wrap the instance in.</param> public AppDomainWrapper(System.AppDomain domain) { // Not a part of .Net Standard or .Net core, but we can call it if we run .Net Framework //m_wrapped = domain.CreateInstanceAndUnwrap(typeof(Runner.AppDomainBridge).Assembly.FullName, typeof(Runner.AppDomainBridge).FullName); var unwrapMethod = domain.GetType().GetMethod("CreateInstanceAndUnwrap", new Type[] { typeof(string), typeof(string) }); m_wrapped = unwrapMethod.Invoke(domain, new object[] { typeof(Runner.AppDomainBridge).Assembly.FullName, typeof(Runner.AppDomainBridge).FullName }); m_setupFromFile = m_wrapped.GetType().GetMethod(nameof(Runner.AppDomainBridge.SetupFromFile)); m_handleRequest = m_wrapped.GetType().GetMethod(nameof(Runner.AppDomainBridge.HandleRequest)); m_stop = m_wrapped.GetType().GetMethod(nameof(Runner.AppDomainBridge.Stop)); m_waitforstop = m_wrapped.GetType().GetMethod(nameof(Runner.AppDomainBridge.WaitForStop)); m_activeclients = m_wrapped.GetType().GetProperty(nameof(Runner.AppDomainBridge.ActiveClients)); if (new[] { m_wrapped, m_setupFromFile, m_handleRequest, m_stop, m_waitforstop }.Any(x => x == null) || m_activeclients == null) { throw new Exception($"Something changed in {typeof(AppDomainBridge)}"); } }