public EdgeAssemblyLoadContext(EdgeAssemblyLoadContextAccessor loadContextAccessor) { DebugMessage("EdgeAssemblyLoadContext::ctor (CLR) - Starting"); DebugMessage("EdgeAssemblyLoadContext::ctor (CLR) - Application root is {0}", RuntimeEnvironment.ApplicationDirectory); _loadContextAccessor = loadContextAccessor; if (File.Exists(Path.Combine(RuntimeEnvironment.ApplicationDirectory, "project.lock.json"))) { IList <LibraryDescription> libraries = ApplicationHostContext.GetRuntimeLibraries(ApplicationHostContext); Dictionary <string, ProjectDescription> projects = libraries.Where(p => p.Type == LibraryTypes.Project).ToDictionary(p => p.Identity.Name, p => (ProjectDescription)p); Dictionary <AssemblyName, string> assemblies = PackageDependencyProvider.ResolvePackageAssemblyPaths(libraries); CompilationEngineContext compilationContext = new CompilationEngineContext(ApplicationEnvironment, RuntimeEnvironment, this, new CompilationCache()); CompilationEngine compilationEngine = new CompilationEngine(compilationContext); AddCompileAssemblies(libraries); _loaders.Add(new ProjectAssemblyLoader(_loadContextAccessor, compilationEngine, projects.Values)); _loaders.Add(new PackageAssemblyLoader(_loadContextAccessor, assemblies, libraries)); } else { _noProjectJsonFile = true; if (File.Exists(Path.Combine(RuntimeEnvironment.EdgeNodePath, "project.lock.json"))) { ApplicationHostContext stockHostContext = new ApplicationHostContext { ProjectDirectory = RuntimeEnvironment.EdgeNodePath, TargetFramework = TargetFrameworkName }; IList <LibraryDescription> libraries = ApplicationHostContext.GetRuntimeLibraries(stockHostContext); Dictionary <AssemblyName, string> assemblies = PackageDependencyProvider.ResolvePackageAssemblyPaths(libraries); AddCompileAssemblies(libraries); _loaders.Add(new PackageAssemblyLoader(_loadContextAccessor, assemblies, libraries)); } } DebugMessage("EdgeAssemblyLoadContext::ctor (CLR) - Created the dependency providers for the application"); }
public static void Initialize(IntPtr context, IntPtr exception) { try { DebugMessage("CoreCLREmbedding::Initialize (CLR) - Starting"); RuntimeEnvironment = new EdgeRuntimeEnvironment(Marshal.PtrToStructure <EdgeBootstrapperContext>(context)); Project project; Project.TryGetProject(RuntimeEnvironment.ApplicationDirectory, out project); ApplicationHostContext = new ApplicationHostContext { ProjectDirectory = RuntimeEnvironment.ApplicationDirectory, TargetFramework = TargetFrameworkName, Project = project }; ApplicationEnvironment = new ApplicationEnvironment(ApplicationHostContext.Project, TargetFrameworkName, "Release", null); LoadContextAccessor = new EdgeAssemblyLoadContextAccessor(); EdgeServiceProvider serviceProvider = new EdgeServiceProvider(); serviceProvider.Add(typeof(IRuntimeEnvironment), RuntimeEnvironment); serviceProvider.Add(typeof(IApplicationEnvironment), ApplicationEnvironment); serviceProvider.Add(typeof(IAssemblyLoadContextAccessor), LoadContextAccessor); CallContextServiceLocator.Locator = new EdgeServiceProviderLocator { ServiceProvider = serviceProvider }; PlatformServices.SetDefault(PlatformServices.Create(null, ApplicationEnvironment, RuntimeEnvironment, null, LoadContextAccessor, null)); DebugMessage("CoreCLREmbedding::Initialize (CLR) - Complete"); } catch (Exception e) { DebugMessage("CoreCLREmbedding::Initialize (CLR) - Exception was thrown: {0}", e.Message); V8Type v8Type; Marshal.WriteIntPtr(exception, MarshalCLRToV8(e, out v8Type)); } }
public EdgeAssemblyLoadContext(EdgeAssemblyLoadContextAccessor loadContextAccessor) { DebugMessage("EdgeAssemblyLoadContext::ctor (CLR) - Starting"); DebugMessage("EdgeAssemblyLoadContext::ctor (CLR) - Application root is {0}", RuntimeEnvironment.ApplicationDirectory); _loadContextAccessor = loadContextAccessor; if (File.Exists(Path.Combine(RuntimeEnvironment.ApplicationDirectory, "project.lock.json"))) { IList <LibraryDescription> libraries = ApplicationHostContext.GetRuntimeLibraries(ApplicationHostContext); Dictionary <string, ProjectDescription> projects = libraries.Where(p => p.Type == LibraryTypes.Project).ToDictionary(p => p.Identity.Name, p => (ProjectDescription)p); Dictionary <AssemblyName, string> assemblies = PackageDependencyProvider.ResolvePackageAssemblyPaths(libraries); CompilationEngineContext compilationContext = new CompilationEngineContext(ApplicationEnvironment, RuntimeEnvironment, this, new CompilationCache()); CompilationEngine compilationEngine = new CompilationEngine(compilationContext); foreach (LibraryDescription libraryDescription in libraries.Where(l => l.Type == LibraryTypes.Package)) { PackageDescription packageDescription = (PackageDescription)libraryDescription; if (packageDescription.Target.CompileTimeAssemblies != null && packageDescription.Target.CompileTimeAssemblies.Count > 0) { CompileAssemblies[libraryDescription.Identity.Name] = Path.Combine(packageDescription.Path, packageDescription.Target.CompileTimeAssemblies[0].Path); } else { CompileAssemblies[libraryDescription.Identity.Name] = Path.Combine(packageDescription.Path, packageDescription.Target.RuntimeAssemblies[0].Path); } } _loaders.Add(new ProjectAssemblyLoader(_loadContextAccessor, compilationEngine, projects.Values)); _loaders.Add(new PackageAssemblyLoader(_loadContextAccessor, assemblies, libraries)); } else { _noProjectJsonFile = true; } DebugMessage("EdgeAssemblyLoadContext::ctor (CLR) - Created the dependency providers for the application"); }
public static void Initialize(IntPtr context, IntPtr exception) { try { DebugMessage("CoreCLREmbedding::Initialize (CLR) - Starting"); RuntimeEnvironment = new EdgeRuntimeEnvironment(Marshal.PtrToStructure<EdgeBootstrapperContext>(context)); Project project; Project.TryGetProject(RuntimeEnvironment.ApplicationDirectory, out project); ApplicationHostContext = new ApplicationHostContext { ProjectDirectory = RuntimeEnvironment.ApplicationDirectory, TargetFramework = TargetFrameworkName, Project = project }; ApplicationEnvironment = new ApplicationEnvironment(ApplicationHostContext.Project, TargetFrameworkName, "Release", null); LoadContextAccessor = new EdgeAssemblyLoadContextAccessor(); EdgeServiceProvider serviceProvider = new EdgeServiceProvider(); serviceProvider.Add(typeof(IRuntimeEnvironment), RuntimeEnvironment); serviceProvider.Add(typeof(IApplicationEnvironment), ApplicationEnvironment); serviceProvider.Add(typeof(IAssemblyLoadContextAccessor), LoadContextAccessor); CallContextServiceLocator.Locator = new EdgeServiceProviderLocator { ServiceProvider = serviceProvider }; PlatformServices.SetDefault(PlatformServices.Create(null, ApplicationEnvironment, RuntimeEnvironment, null, LoadContextAccessor, null)); DebugMessage("CoreCLREmbedding::Initialize (CLR) - Complete"); } catch (Exception e) { DebugMessage("CoreCLREmbedding::Initialize (CLR) - Exception was thrown: {0}", e.Message); V8Type v8Type; Marshal.WriteIntPtr(exception, MarshalCLRToV8(e, out v8Type)); } }
public EdgeAssemblyLoadContext(EdgeAssemblyLoadContextAccessor loadContextAccessor) { DebugMessage("EdgeAssemblyLoadContext::ctor (CLR) - Starting"); DebugMessage("EdgeAssemblyLoadContext::ctor (CLR) - Application root is {0}", RuntimeEnvironment.ApplicationDirectory); _loadContextAccessor = loadContextAccessor; if (File.Exists(Path.Combine(RuntimeEnvironment.ApplicationDirectory, "project.lock.json"))) { IList<LibraryDescription> libraries = ApplicationHostContext.GetRuntimeLibraries(ApplicationHostContext); Dictionary<string, ProjectDescription> projects = libraries.Where(p => p.Type == LibraryTypes.Project).ToDictionary(p => p.Identity.Name, p => (ProjectDescription)p); Dictionary<AssemblyName, string> assemblies = PackageDependencyProvider.ResolvePackageAssemblyPaths(libraries); CompilationEngineContext compilationContext = new CompilationEngineContext(ApplicationEnvironment, RuntimeEnvironment, this, new CompilationCache()); CompilationEngine compilationEngine = new CompilationEngine(compilationContext); AddCompileAssemblies(libraries); _loaders.Add(new ProjectAssemblyLoader(_loadContextAccessor, compilationEngine, projects.Values)); _loaders.Add(new PackageAssemblyLoader(_loadContextAccessor, assemblies, libraries)); } else { _noProjectJsonFile = true; if (File.Exists(Path.Combine(RuntimeEnvironment.EdgeNodePath, "project.lock.json"))) { ApplicationHostContext stockHostContext = new ApplicationHostContext { ProjectDirectory = RuntimeEnvironment.EdgeNodePath, TargetFramework = TargetFrameworkName }; IList<LibraryDescription> libraries = ApplicationHostContext.GetRuntimeLibraries(stockHostContext); Dictionary<AssemblyName, string> assemblies = PackageDependencyProvider.ResolvePackageAssemblyPaths(libraries); AddCompileAssemblies(libraries); _loaders.Add(new PackageAssemblyLoader(_loadContextAccessor, assemblies, libraries)); } } DebugMessage("EdgeAssemblyLoadContext::ctor (CLR) - Created the dependency providers for the application"); }