コード例 #1
0
        public static void Initialize()
        {
            var IsDeveloperRuntime = StartupFactory.IsDeveloperRuntime();

            try
            {
                if (Debug.IsDeveloper)
                {
                    Debug.WriteLine($"{typeof(OnWeb.NamespaceAnchor).Name}.Start: process='{System.Diagnostics.Process.GetCurrentProcess().ProcessName}'");
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"{typeof(OnWeb.NamespaceAnchor).Name}.Start: error {ex.ToString()}");
            }

            try
            {
                Binding.Razor.WebStartup.Initialize();
            }
            catch (Exception ex) { Debug.WriteLine($"{typeof(OnWeb.NamespaceAnchor).Name}.ModuleInitializer Error: {ex.ToString()}"); }

            if (!IsDeveloperRuntime)
            {
                CheckMSDTC();
            }
        }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the type
        /// </summary>
        /// <param name="configuration">The configuration for the Kestrel Server</param>
        /// <param name="loggerFactory">A factory to create loggers from</param>
        /// <param name="factory">An optional factory for the startup type</param>
        public KestrelHost(IKestrelHostConfiguration configuration, ILoggerFactory loggerFactory, StartupFactory factory = null)
        {
            Guard.NotNull(nameof(configuration), configuration);
            Guard.NotNull(nameof(configuration.Address), configuration.Address);
            Guard.NotLessThan(nameof(configuration.KeepAlive), configuration.KeepAlive, TimeSpan.FromSeconds(1));
            Guard.NotLessThan(nameof(configuration.MaximumConcurrentConnections), configuration.MaximumConcurrentConnections, 1);
            Guard.NotNull(nameof(loggerFactory), loggerFactory);

            _logger        = loggerFactory.CreateLogger("Kestrel Host");
            _configuration = configuration;
            _factory       = factory;
        }
コード例 #3
0
ファイル: WebInitializer.cs プロジェクト: Sellec/OnXap
        public static void Initialize()
        {
            var IsDeveloperRuntime = StartupFactory.IsDeveloperRuntime();

            try
            {
                WebStartup.Initialize();
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"{typeof(WebInitializer).FullName} Error: {ex.ToString()}");
            }

            if (!IsDeveloperRuntime)
            {
                CheckMSDTC();
            }
        }
コード例 #4
0
    /// <summary>
    /// Initializes the module.
    /// </summary>
    public static void Initialize()
    {
        try
        {
            var IsDeveloperRuntime = StartupFactory.IsDeveloperRuntime();

            if (IsDeveloperRuntime)
            {
                var assemblyReferences = typeof(StartupFactory).Assembly.GetReferencedAssemblies();
                foreach (var assembly in assemblyReferences)
                {
                    try { Assembly.Load(assembly.FullName); }
                    catch { }
                }
            }


            bool IsNeedStartup = !IsDeveloperRuntime;   //Для сред разработки НЕ надо грузить библиотеки.

            var entryAssembly = Assembly.GetEntryAssembly();
            if (entryAssembly != null)
            {
                var attr = entryAssembly.GetCustomAttributes(typeof(StartupBehaviourAttribute), true).FirstOrDefault();
                if (attr != null)
                {
                    IsNeedStartup = (attr as StartupBehaviourAttribute).IsNeedStartupFactoryAuto;
                }
            }

            if (IsNeedStartup)
            {
                StartupFactory.Startup();
            }
        }
        catch (Exception ex) { Debug.WriteLine("Core.ModuleInitializer Error: {0}", ex.ToString()); }
    }
コード例 #5
0
ファイル: WebInitializer.cs プロジェクト: Sellec/OnWeb
        public static void Initialize()
        {
            var IsDeveloperRuntime = StartupFactory.IsDeveloperRuntime();

            try
            {
                if (Debug.IsDeveloper)
                {
                    Debug.WriteLine($"{typeof(OnWeb.NamespaceAnchor).Name}.Start: process='{System.Diagnostics.Process.GetCurrentProcess().ProcessName}'");
                }

                if (System.Diagnostics.Process.GetCurrentProcess().ProcessName == "Microsoft.VisualStudio.Web.Host")
                {
                    var runtimeVersion      = IntPtr.Size == 4 ? "32" : "64";
                    var managerInjectorType = IntPtr.Size == 4 ?
                                              Type.GetType("ManagedInjector.Injector, ManagedInjector-x86, Version=1.0.7025.18016, Culture=neutral, PublicKeyToken=8e22adab863b765a", false) :
                                              Type.GetType("ManagedInjector.Injector, ManagedInjector-x64, Version=1.0.7025.18014, Culture=neutral, PublicKeyToken=8e22adab863b765a", false);

                    if (Debug.IsDeveloper)
                    {
                        Debug.WriteLine($"{typeof(OnWeb.NamespaceAnchor).Name}.Start: managerInjectorType='{managerInjectorType?.ToString()}'");
                    }
                    if (managerInjectorType != null)
                    {
                        var launchMethod       = managerInjectorType.GetMethod("Launch");
                        var loadAssemblyMethod = managerInjectorType.GetMethod("LoadAssembly");
                        if (launchMethod != null && loadAssemblyMethod != null)
                        {
                            var utilsInjectorType = typeof(ModuleInjector);
                            var webInjectorType   = typeof(WebRazorHostFactoryInjector);

                            var newtonsoftAssembly  = typeof(Newtonsoft.Json.JsonSerializer).Assembly;
                            var utilsAssembly       = utilsInjectorType.Assembly;
                            var applicationAssembly = typeof(ApplicationBase <>).Assembly;
                            var mvcAssembly         = typeof(System.Web.Mvc.ActionResult).Assembly;
                            var webCoreAssembly     = typeof(ApplicationCore).Assembly;
                            var webAssembly         = webInjectorType.Assembly;

                            //var webAssemblyReferences = webAssembly.GetReferencedAssemblies().Select(x => System.Reflection.Assembly.Load(x.FullName)).ToList();
                            //try
                            //{
                            //}
                            //catch (Exception ex)
                            //{

                            //}

                            var devEnvProcesses = System.Diagnostics.Process.GetProcessesByName("devenv");
                            foreach (var process in devEnvProcesses)
                            {
                                try
                                {
                                    // launchMethod.Invoke(null, new object[] { process.MainWindowHandle, newtonsoftAssembly.Location, "", "" });
                                    launchMethod.Invoke(null, new object[] { process.MainWindowHandle, utilsAssembly.Location, utilsInjectorType.FullName, nameof(ModuleInjector.InjectorLoader) });
                                    loadAssemblyMethod.Invoke(null, new object[] { process.MainWindowHandle, applicationAssembly.Location });
                                    loadAssemblyMethod.Invoke(null, new object[] { process.MainWindowHandle, mvcAssembly.Location });
                                    //foreach (var webAssemblyReference in webAssemblyReferences)
                                    //{
                                    //    try
                                    //    {
                                    //        loadAssemblyMethod.Invoke(null, new object[] { process.MainWindowHandle, webAssemblyReference.Location });
                                    //    }
                                    //    catch (Exception ex)
                                    //    {
                                    //        Debug.WriteLine($"{typeof(OnWeb.NamespaceAnchor).Name}.Start: process '{process.ProcessName}' (pid {process.Id}), error loading web assembly - '{webAssembly.FullName}'");
                                    //    }
                                    //}
                                    loadAssemblyMethod.Invoke(null, new object[] { process.MainWindowHandle, webCoreAssembly.Location });
                                    launchMethod.Invoke(null, new object[] { process.MainWindowHandle, webAssembly.Location, webInjectorType.FullName, nameof(WebRazorHostFactoryInjector.LoadIntoHost) });
                                    Debug.WriteLine($"{typeof(OnWeb.NamespaceAnchor).Name}.Start: process '{process.ProcessName}' (pid {process.Id}), success");
                                }
                                catch (Exception ex)
                                {
                                    Debug.WriteLine(typeof(OnWeb.NamespaceAnchor).Name + ".Start: process '{0}' (pid {1}), error: {2}", process.ProcessName, process.Id, ex.ToString());
                                }
                            }
                        }
                        else if (launchMethod == null && loadAssemblyMethod == null && Debug.IsDeveloper)
                        {
                            Debug.WriteLine($"{typeof(OnWeb.NamespaceAnchor).Name}.Start: launch && loadAssemblyMethod method not found");
                        }
                        else if (launchMethod == null && Debug.IsDeveloper)
                        {
                            Debug.WriteLine($"{typeof(OnWeb.NamespaceAnchor).Name}.Start: launch method not found");
                        }
                        else if (loadAssemblyMethod == null && Debug.IsDeveloper)
                        {
                            Debug.WriteLine($"{typeof(OnWeb.NamespaceAnchor).Name}.Start: loadAssemblyMethod method not found");
                        }
                    }
                    else if (Debug.IsDeveloper)
                    {
                        Debug.WriteLine($"{typeof(OnWeb.NamespaceAnchor).Name}.Start: not managerInjectorType");
                    }
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"{typeof(OnWeb.NamespaceAnchor).Name}.Start: error {ex.ToString()}");
            }

            try
            {
                Razor.WebStartup.Initialize();
            }
            catch (Exception ex) { Debug.WriteLine($"{typeof(OnWeb.NamespaceAnchor).Name}.ModuleInitializer Error: {ex.ToString()}"); }

            if (!IsDeveloperRuntime)
            {
                CheckMSDTC();
            }
        }
コード例 #6
0
 /// <summary>
 /// Initializes a new instance of the type
 /// </summary>
 /// <param name="configuration">The configuration for the Kestrel Server</param>
 /// <param name="loggerFactory">A factory to create loggers from</param>
 /// <param name="factory">An optional factory for the startup type</param>
 public KestrelProbeHost(IKestrelHostConfiguration configuration, ILoggerFactory loggerFactory, StartupFactory factory = null)
     : base(configuration, loggerFactory, factory)
 {
 }