Exemple #1
0
        private static JobApplicationHost CreateAppHost(string path)
        {
            var result = ApplicationHost.CreateApplicationHost(
                typeof(JobApplicationHost),
                "/",
                path);

            return((JobApplicationHost)result);
        }
        public void Constructor_SerializableType()
        {
            object o = ApplicationHost.CreateApplicationHost(typeof(MySerializable), "/app", Environment.CurrentDirectory);

            Assert.AreEqual(typeof(MySerializable), o.GetType(), "C2");
            MySerializable m = (MySerializable)o;

            Assert.AreEqual(m.GetDomainName(), AppDomain.CurrentDomain.FriendlyName, "C4");
        }
Exemple #3
0
 public void createHost()
 {
     //if (WebServerHost.isNull())
     {
         var o2Timer = new O2Timer("Creating WebServer host").start();
         WebServerHost = (WebServerHost)ApplicationHost.CreateApplicationHost(typeof(WebServerHost), "/", WebRootDir);
         //WebServerHost = ApplicationHost.CreateApplicationHost(typeof(WebServerHost), "/", WebRootDir);
         o2Timer.stop();
     }
 }
        private readonly AppDomainProxy _appDomainProxy; // The gateway to the ASP.NET-enabled .NET appdomain

        private AppHost(string appPhysicalDirectory, string virtualDirectory = "/")
        {
            _appDomainProxy = (AppDomainProxy)ApplicationHost.CreateApplicationHost(typeof(AppDomainProxy), virtualDirectory, appPhysicalDirectory);
            _appDomainProxy.RunCodeInAppDomain(() =>
            {
                InitializeApplication();
                FilterProviders.Providers.Add(new InterceptionFilterProvider());
                LastRequestData.Reset();
            });
        }
Exemple #5
0
        public AppHost(string appPhysicalDirectory, string virtualDirectory)
        {
            appDomainProxy = (AppDomainProxy)ApplicationHost.CreateApplicationHost(typeof(AppDomainProxy), virtualDirectory, appPhysicalDirectory);

            appDomainProxy.RunCodeInAppDomain(() => {
                InitializeApplication();
                var filters = System.Web.Mvc.GlobalFilters.Filters;
                filters.Add(new InterceptionFilter(), int.MaxValue);
                LastRequestData.Reset();
            });
        }
Exemple #6
0
    public static void Main(String[] arguments)
    {
        ASPX2HTML host = (ASPX2HTML)ApplicationHost.CreateApplicationHost(typeof(ASPX2HTML), "/foo",
                                                                          Directory.CurrentDirectory);

        foreach (String aspx in arguments)
        {
            Console.Out.WriteLine("file:" + aspx);
            host.ProcessRequest(aspx);
        }
    }
Exemple #7
0
        public void Start()
        {
            _listening = true;

            _listener = (HttpListenerWrapper)ApplicationHost.CreateApplicationHost(
                typeof(HttpListenerWrapper), _virtualDir, _physicalDir);
            _listener.Configure(_prefixes, _virtualDir, _physicalDir);
            _listener.Start();

            _pump = new Thread(Pump);
            _pump.Start();
        }
Exemple #8
0
        /**
         * Called to configure a Physical directory as a Virtual alias.
         * To configure a directory as a AspxApplication, the exe for this project ASPXhostCS.exe
         * and ASPXHostCS.exe.config (if present) should be present in the bin directory under
         * the physical directory being configured. The reason being, that the call to API
         * ApplicationHost.CreateApplicationhost creates a new app domain and will instantiate
         * a class specified in the typeof variable. Putting it in the bin directory enables
         * the hosting api to load the class.
         */
        internal AspxNetEngine(String virtualAlias, String physicalDir)
        {
            m_VirtualAlias      = virtualAlias;
            m_PhysicalDirectory = physicalDir;

            //m_ExecutingEngine will be the actual object that the hosting API created for
            //us and so to execute a page in the Application we will call this object to
            //process requests
            CreateAssemblyInBin(m_PhysicalDirectory);
            m_ExecutingAppDomain = (AspxNetEngine)ApplicationHost.CreateApplicationHost(typeof(AspxNetEngine), m_VirtualAlias, m_PhysicalDirectory);
            m_ExecutingAppDomain.PhysicalDirectory = m_PhysicalDirectory;
        }
Exemple #9
0
    public static TinyHost CreateHost()
    {
        string path = Directory.GetCurrentDirectory();
        string bin  = Path.Combine(path, "bin");
        string asm  = Path.GetFileName(typeof(TinyHost).Assembly.Location);

        Directory.CreateDirectory(bin);
        File.Copy(asm, Path.Combine(bin, asm), true);

        return((TinyHost)ApplicationHost.CreateApplicationHost(
                   typeof(TinyHost), "/", path));
    }
Exemple #10
0
 public override void Load()
 {
     base.Load();
     if (host == null)
     {
         Type type = typeof(WebApplicationHost);
         host = (WebApplicationHost)ApplicationHost.CreateApplicationHost(type, VirtualDirectory, BaseDirectory);
         host.SetListenAddress(Port);
     }
     host.Start();
     _Loaded = true;
 }
Exemple #11
0
 private void CreateHost()
 {
     if (_handler == null)
     {
         _host = (Host)ApplicationHost.CreateApplicationHost(typeof(Host), _virtualPath, _physicalPath);
     }
     else
     {
         _host = new Host();
     }
     _host.Configure(this, _port, _virtualPath, _physicalPath, _installPath, _handler);
 }
Exemple #12
0
        public static TestASPAppHost GetHost(string webRootPath)
        {
            var host = (TestASPAppHost)ApplicationHost.CreateApplicationHost(
                typeof(TestASPAppHost),
                "/test",
                webRootPath);

            // Run a bogus request through the pipeline to wake up ASP.NET and initialize everything
            host.InitASPNET();

            return(host);
        }
Exemple #13
0
        public static MvcAppHost CreateApplicationHost <T>() where T : HttpApplication, new()
        {
            var host = (MvcAppHost)ApplicationHost.CreateApplicationHost(
                typeof(MvcAppHost),
                "/",
                ApplicationPath);

            host.TempBinPath = BinTarget;
            host.InitializeApplication <T>();

            return(host);
        }
Exemple #14
0
 private void CreateApplicationHost()
 {
     try {
         ApplicationHost.CreateApplicationHost(null, null, null);
     }
     catch (NullReferenceException) {
         // MS
     }
     catch (NotImplementedException) {
         // Mono
     }
 }
        public static AspNetBridge GetBridge(string Url)
        {
            string Directory = DirectoryFromUrl(Url);

            object host = HostMap[Directory];

            if (host == null)
            {
                host = ApplicationHost.CreateApplicationHost(typeof(AspNetBridge), "/", Directory);
                HostMap[Directory] = host;
            }
            return((AspNetBridge)host);
        }
Exemple #16
0
        private AspNetRemote CreateAspNetRemote(AspNetAdapterArguments arguments)
        {
            // pretty terrible, any better ideas?
            var assembly = Assembly.GetExecutingAssembly();

            File.Copy(assembly.Location, Path.Combine(arguments.ApplicationPhysicalPath, "bin", Path.GetFileName(assembly.Location)), true);
            // might be useful to copy dependencies as well

            var remote = (AspNetRemote)ApplicationHost.CreateApplicationHost(typeof(AspNetRemote), "/", arguments.ApplicationPhysicalPath);

            remote.SetApplicationData(arguments.ApplicationData);
            return(remote);
        }
        [Category("NotDotNet")]          // D2 and D3 asserts will fail in windows on because file system environment
        public void ConstructorTest()
        {
            object o = ApplicationHost.CreateApplicationHost(typeof(MBR), "/app", Environment.CurrentDirectory);

            Assert.AreEqual(typeof(MBR), o.GetType(), "C5");
            MBR m = (MBR)o;

            Assert.AreEqual(true, m.GetDomainName() != AppDomain.CurrentDomain.FriendlyName);

            AppDomain      other = m.GetDomain();
            AppDomainSetup setup = other.SetupInformation;

            string tb = Environment.CurrentDirectory;

            if (tb[tb.Length - 1] == Path.DirectorySeparatorChar)
            {
                tb = tb.Substring(0, tb.Length - 1);
            }

            // Need to fix an issue in AppDomainSetup
            // Assert.AreEqual (tb + "/", setup.ApplicationBase, "D1");

            p("AppDomain's Applicationname is: ", setup.ApplicationName);
            // IGNORE this test. We are setting CachePath to DynamicBase by now.
            // Assert.AreEqual (null, setup.CachePath, "D2");

            Assert.AreEqual(0, String.Compare(tb + Path.DirectorySeparatorChar + "Web.Config", setup.ConfigurationFile, StringComparison.OrdinalIgnoreCase), "D3");
            Assert.AreEqual(false, setup.DisallowBindingRedirects, "D4");
            Assert.AreEqual(true, setup.DisallowCodeDownload, "D5");
            Assert.AreEqual(false, setup.DisallowPublisherPolicy, "D6");
            // Disabling D7 test, as we set it there to avoid locking in sys.web.compilation
            // Assert.AreEqual (null, setup.DynamicBase, "D7");
            Assert.AreEqual(null, setup.LicenseFile, "D8");
            //Assert.AreEqual (LoaderOptimization.NotSpecified, setup.LoaderOptimization);
            p("LoaderOptimization is: ", setup.LoaderOptimization);
            Assert.AreEqual(0, string.Compare(
#if NET_2_0
                                String.Format("{0}{1}bin", tb, Path.DirectorySeparatorChar),
#else
                                "bin",
#endif
                                setup.PrivateBinPath, true), "D9"
                            );
            Assert.AreEqual(setup.PrivateBinPathProbe, "*", "D10");
            p("ShadowCopyDirs: ", setup.ShadowCopyDirectories);
            Assert.AreEqual(true, setup.ShadowCopyDirectories.EndsWith("bin") || setup.ShadowCopyDirectories.EndsWith("Bin"), "D11");
            Assert.AreEqual(false, setup.ShadowCopyDirectories.StartsWith("file:"), "D12");
            Assert.AreEqual("true", setup.ShadowCopyFiles, "D13");

            p("ApsInstal", HttpRuntime.AspInstallDirectory);
        }
Exemple #18
0
        /**
         * Called to configure a Physical directory as a Virtual alias.
         * To configure a directory as a AspxApplication, the exe for this project ASPXhostCS.exe
         * and ASPXHostCS.exe.config (if present) should be present in the bin directory under
         * the physical directory being configured. The reason being, that the call to API
         * ApplicationHost.CreateApplicationhost creates a new app domain and will instantiate
         * a class specified in the typeof variable. Putting it in the bin directory enables
         * the hosting api to load the class.
         */
        internal AspxNetEngine(String virtualAlias, String physicalDir)
        {
            m_VirtualAlias      = virtualAlias;
            m_PhysicalDirectory = physicalDir;

            Console.WriteLine("Creating a new AspxEngine.");

            //m_ExecutingEngine will be the actual object that the hosting API created for
            //us and so to execute a page in the Application we will call this object to
            //process requests
            m_ExecutingAppDomain = (AspxNetEngine)ApplicationHost.CreateApplicationHost(typeof(AspxNetEngine), m_VirtualAlias, m_PhysicalDirectory);

            Console.WriteLine("New AspxEngine created for alias " + m_VirtualAlias);
        }
 private bool Start()
 {
     try
     {
         _aspHost = (SimpleAspNetHost)ApplicationHost.CreateApplicationHost(
             typeof(SimpleAspNetHost), "/", AppPath);
     }
     catch (Exception ex)
     {
         ServerLog.Write(ex);
         return(false);
     }
     return(true);
 }
Exemple #20
0
        static void Main(string[] args)
        {
            string       path   = Path.Combine(Directory.GetCurrentDirectory(), "Root");
            SimpleServer server = (SimpleServer)ApplicationHost.CreateApplicationHost(typeof(SimpleServer), "/", path);

            server.AppDomainConnect();
            server.Start();

            Console.WriteLine("Press any key to stop the fastcgi server");
            Console.ReadKey();

            server.Stop();
            server.AppDomainDisconnect();
        }
Exemple #21
0
        public void CreateHost(ApplicationServer server, WebSource webSource)
        {
            string v = vpath;

            if (v != "/" && v.EndsWith("/"))
            {
                v = v.Substring(0, v.Length - 1);
            }

            AppHost        = ApplicationHost.CreateApplicationHost(webSource.GetApplicationHostType(), v, realPath) as IApplicationHost;
            AppHost.Server = server;

            // Link the host in the application domain with a request broker in the main domain
            RequestBroker         = webSource.CreateRequestBroker();
            AppHost.RequestBroker = RequestBroker;
        }
    public static void Main(string[] args)
    {
        var appDomain = ((AppDomainUnveiler)ApplicationHost.CreateApplicationHost(
                             typeof(AppDomainUnveiler),
                             "/",
                             Path.GetFullPath("../Path/To/WebAppRoot"))).GetAppDomain();

        try
        {
            appDomain.DoCallback(TestHarness);
        }
        finally
        {
            AppDomain.Unload(appDomain);
        }
    }
        private static AppHost GetHost(string virtualDir, string physicalPath)
        {
            if (!(physicalPath.EndsWith("\\")))
            {
                physicalPath += "\\";
            }

#if DEBUG
            _staticlog.InfoFormat("Setting up app domain on virtual dir {0} - physical path {1}", virtualDir, physicalPath);
#endif
            var host = (AppHost)ApplicationHost.CreateApplicationHost(typeof(AppHost), virtualDir, physicalPath);
            host.PPath            = physicalPath;
            host.VPath            = virtualDir;
            host.DefaultAppDomain = AppDomain.CurrentDomain;

            return(host);
        }
Exemple #24
0
        public TwitchBot()
        {
            mTcpConnection = new TcpConnection();
            mTcpConnection.DataReceived += ProccessMessageData;
            mTcpConnection.EmergencyDisc = EmergencyReset;
            mIrcCommandAnalyzer          = new SimpleTwitchBotIrcCommandAnalyzer();

            host = (CustomHost)ApplicationHost.CreateApplicationHost(typeof(CustomHost), "/", Directory.GetParent(Directory.GetCurrentDirectory()).FullName);

            StartHttpListener();
            mQE                            = new QuizEngine();
            mQE.SendMessage                = SendMessageToCurrentChannel;
            mQE.PropertyChanged           += ProxyPassNotifyPropertyChanged;
            mQE.InternalInitiationQuizStop = StopQuiz;

            TwitchChannel = "NONE";
        }
Exemple #25
0
        private void StartAspNetHost(string virtualDirectory) {
            Log("Starting up ASP.NET host");
            HostName = "localhost";
            PhysicalDirectory = _tempSite;
            VirtualDirectory = virtualDirectory;

            _webHostAgent = (WebHostAgent)ApplicationHost.CreateApplicationHost(typeof(WebHostAgent), VirtualDirectory, PhysicalDirectory);


            var shuttle = new Shuttle();
            Execute(() => { shuttle.CodeGenDir = HttpRuntime.CodegenDir; });

            // ASP.NET folder seems to be always nested into an empty directory
            _codeGenDir = shuttle.CodeGenDir;
            _codeGenDir = _codeGenDir.Parent;
            Log("ASP.NET CodeGenDir: \"{0}\"", _codeGenDir);
        }
        public HttpListenerController(string vdir, string pdir)
        {
            _virtualDir  = vdir;
            _physicalDir = pdir;

            var dllpath = this.GetType().Assembly.Location;
            var binpath = System.IO.Path.Combine(pdir, "bin", System.IO.Path.GetFileName(dllpath));

            if (!System.IO.File.Exists(binpath))
            {
                IO.FileHelper.CopyFile(dllpath, System.IO.Path.Combine(pdir, "bin", System.IO.Path.GetFileName(dllpath)));
            }

            _listener = (HttpListenerWrapper)ApplicationHost.CreateApplicationHost(
                typeof(HttpListenerWrapper), _virtualDir, _physicalDir);
            _listener.Configure(_virtualDir, _physicalDir);
        }
Exemple #27
0
        public static void SetupHosting(WebTestResourcesSetupAttribute.SetupHandler resHandler)
        {
#if !TARGET_JVM
            if (host == null)
            {
                host = AppDomain.CurrentDomain.GetData(HOST_INSTANCE_NAME) as MyHost;
            }
#endif
            if (host != null)
            {
                CleanApp();
            }
#if TARGET_JVM
            host = new MyHost();
            return;
#else
            if (resHandler == null)
            {
                resHandler = CheckResourcesSetupHandler();
            }
            if (resHandler == null)
            {
                CopyResources();
            }
            else
            {
                resHandler();
            }

            foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies())
            {
                LoadAssemblyRecursive(ass);
            }

            foreach (Assembly ass in AppDomain.CurrentDomain.GetAssemblies())
            {
                CopyAssembly(ass, binDir);
            }

            host = (MyHost)ApplicationHost.CreateApplicationHost(typeof(MyHost), VIRTUAL_BASE_DIR, baseDir);
            AppDomain.CurrentDomain.SetData(HOST_INSTANCE_NAME, host);
            host.AppDomain.SetData(HOST_INSTANCE_NAME, host);
            host.AppDomain.DomainUnload += new EventHandler(_unloadHandler.OnUnload);
#endif
        }
Exemple #28
0
        private readonly AppDomainProxy _appDomainProxy; // The gateway to the ASP.NET-enabled .NET appdomain

        private AppHost(string appPhysicalDirectory, string virtualDirectory = "/")
        {
            try {
                _appDomainProxy = (AppDomainProxy)ApplicationHost.CreateApplicationHost(typeof(AppDomainProxy), virtualDirectory, appPhysicalDirectory);
            } catch (FileNotFoundException ex) {
                if ((ex.Message != null) && ex.Message.Contains("MvcIntegrationTestFramework"))
                {
                    throw new InvalidOperationException("Could not load MvcIntegrationTestFramework.dll within a bin directory under " + appPhysicalDirectory + ". Is this the path to your ASP.NET MVC application, and have you set up a post-build event to copy your test assemblies and their dependencies to this folder? See the demo project for an example.");
                }
                throw;
            }

            _appDomainProxy.RunCodeInAppDomain(() => {
                InitializeApplication();
                AttachTestControllerDescriptorsForAllControllers();
                LastRequestData.Reset();
            });
        }
Exemple #29
0
        static void Main(string[] args)
        {
            int    port;
            string dir = Directory.GetCurrentDirectory();

            if (args.Length == 0 || !int.TryParse(args[0], out port))
            {
                port = 45758;
            }

            InitHostFile(dir);
            SimpleHost host = (SimpleHost)ApplicationHost.CreateApplicationHost(typeof(SimpleHost), "/", dir);

            host.Config("/", dir);

            WebServer server = new WebServer(host, port);

            server.Start();
        }
Exemple #30
0
        static void Main(string[] args)
        {
            int    port;
            string dir = Directory.GetCurrentDirectory();

            if (args.Length == 0 || !int.TryParse(args[0], out port))
            {
                port = int.Parse(Config.CreatInstance().GetConfigValue("port"));
            }

            InitHostFile(dir);
            LyoHost host = (LyoHost)ApplicationHost.CreateApplicationHost(typeof(LyoHost), "/", dir);

            host.Config("/", dir);

            WebServer server = new WebServer(host, port);

            server.Start();
        }