Runtime: Proposal: hostfxr_get_clr_properties to get all the information needed to self-host host a clr runtime.

Created on 3 Sep 2018  路  28Comments  路  Source: dotnet/runtime

Currently, we can invoke hostfxr in a hosted setup, but only invoke a Program.Main.

I need to host a runtime that I control myself, using coreclrhost.h (here). To do this, I need to know all the information needed to start a runtime.

  1. The coreclr path so that I can load and invoke it.
  2. All the properties that were passed to the coreclr. This includes any runtime properties (eg, System.GC.Server), TRUSTED_PLATFORM_ASSEMBLIES, APP_PATHS, etc, etc.

There is already a hostfxr_get_native_search_directories method, but it only returns a piece of the puzzle.

I'd like to create a pull request that adds a hostfxr_get_clr_properties method. This method would return a JSON object (serialized as string) that contains all the info needed to host a coreclr runtime.

This is what I'm thinking for the returned JSON object.

{
    "coreclrPath": "/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/libcoreclr.dylib",
    "properties": {
        "TRUSTED_PLATFORM_ASSEMBLIES": "...",
        "APP_PATHS": "..."
        "NATIVE_DLL_SEARCH_DIRECTORIES": "..."
    }
}

The properties property would contain every property that is listed here.

With this information, we can self-host a .NET Core runtime with greater control on the lifetime of the runtime and what is done with the runtime.

Maybe I'm totally off base. Maybe there is another way to self-host .NET Core while utilizing deps.json and runtimeconfig.json? I'd love some input before I begin.

area-Host

All 28 comments

I went ahead and added the function in a fork.

https://github.com/pauldotknopf/core-setup/commit/aebbcef9160d64364a9934790d145f852ae1dd00

I've ran it locally, and this is my JSON output.

{
  "coreclr_path": "/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/libcoreclr.dylib",
  "properties": {
    "APP_CONTEXT_BASE_DIRECTORY": "/Users/pknopf/temp/TestWeb/bin/Debug/netcoreapp2.1/",
    "APP_CONTEXT_DEPS_FILES": "/Users/pknopf/temp/TestWeb/bin/Debug/netcoreapp2.1/TestWeb.deps.json;/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.App.deps.json;/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/Microsoft.NETCore.App.deps.json",
    "AppDomainCompatSwitch": "UseLatestBehaviorWhenTFMNotSpecified",
    "FX_DEPS_FILE": "/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/Microsoft.NETCore.App.deps.json",
    "JIT_PATH": "/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/libclrjit.dylib",
    "NATIVE_DLL_SEARCH_DIRECTORIES": "/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3:",
    "PLATFORM_RESOURCE_ROOTS": "",
    "PROBING_DIRECTORIES": "/Users/pknopf/.nuget/packages:/usr/local/share/dotnet/sdk/NuGetFallbackFolder:",
    "System.GC.Server": "true",
    "TRUSTED_PLATFORM_ASSEMBLIES": "/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/mscorlib.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Xml.Serialization.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Xml.ReaderWriter.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Xml.Linq.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Web.HttpUtility.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Transactions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Transactions.Local.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Threading.Timer.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Threading.Thread.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Threading.Tasks.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Threading.Tasks.Parallel.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.ServiceProcess.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.ServiceModel.Web.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Security.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Security.SecureString.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Security.Cryptography.X509Certificates.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Security.Cryptography.Encoding.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Security.Cryptography.Csp.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Xml.XDocument.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Text.RegularExpressions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Security.Cryptography.Cng.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Security.Claims.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Security.AccessControl.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Runtime.Serialization.Xml.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Runtime.Serialization.Formatters.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Runtime.Loader.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Runtime.InteropServices.RuntimeInformation.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Runtime.Handles.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Runtime.CompilerServices.VisualC.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Resources.Writer.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Reflection.Metadata.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Reflection.Extensions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Reflection.Emit.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Security.Principal.Windows.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Reflection.Emit.ILGeneration.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Private.Xml.Linq.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Private.Uri.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.ObjectModel.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Numerics.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.WebSockets.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.WebSockets.Client.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.WebProxy.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.WebClient.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.Sockets.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Xml.XmlDocument.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.ServicePoint.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Reflection.Primitives.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.Security.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.Primitives.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.Ping.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.Mail.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.HttpListener.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.Http.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Xml.XmlSerializer.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Linq.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Linq.Expressions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.IO.Pipes.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.IO.Pipes.AccessControl.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Memory.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.IO.MemoryMappedFiles.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Security.Cryptography.Primitives.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.IO.IsolatedStorage.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Windows.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.IO.FileSystem.Primitives.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Linq.Parallel.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.IO.FileSystem.DriveInfo.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.IO.Compression.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.IO.Compression.FileSystem.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.IO.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.IO.Compression.Brotli.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Globalization.Extensions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Drawing.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Drawing.Primitives.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Diagnostics.TraceSource.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Diagnostics.Tools.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Security.Cryptography.Algorithms.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Diagnostics.TextWriterTraceListener.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Http.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/Microsoft.Win32.Registry.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Diagnostics.FileVersionInfo.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Data.Common.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Console.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Net.Http.Headers.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.ComponentModel.Annotations.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.ComponentModel.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Collections.NonGeneric.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.AppContext.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.EntityFrameworkCore.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Configuration.UserSecrets.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/SOS.NETCore.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/Microsoft.Win32.Primitives.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Hosting.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/Microsoft.VisualBasic.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/Microsoft.CSharp.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/System.Threading.Channels.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/System.Text.Encoding.CodePages.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Runtime.Serialization.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/System.Security.Cryptography.Xml.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/System.Runtime.CompilerServices.Unsafe.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/System.Interactive.Async.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/System.IdentityModel.Tokens.Jwt.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/System.IO.Pipelines.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Remotion.Linq.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Logging.Debug.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Newtonsoft.Json.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Newtonsoft.Json.Bson.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.IdentityModel.Tokens.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Authentication.Twitter.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Mvc.Razor.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Diagnostics.Process.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.DependencyInjection.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.IdentityModel.Protocols.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.ComponentModel.TypeConverter.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Caching.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.ComponentModel.DataAnnotations.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.IdentityModel.Protocols.WsFederation.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Collections.Concurrent.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.IdentityModel.Protocols.OpenIdConnect.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Xml.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Dynamic.Runtime.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Options.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.IO.FileSystem.Watcher.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Options.ConfigurationExtensions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.ComponentModel.EventBasedAsync.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.ObjectPool.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Threading.Overlapped.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.ComponentModel.Primitives.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Logging.EventSource.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Core.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/System.Security.Permissions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Localization.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Routing.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.DependencyInjection.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Localization.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Logging.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Identity.Stores.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Reflection.DispatchProxy.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Hosting.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.FileSystemGlobbing.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.FileProviders.Physical.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Threading.Tasks.Extensions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/System.Text.Encodings.Web.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.FileProviders.Composite.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.FileProviders.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Diagnostics.DiagnosticSource.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Identity.Core.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.DiagnosticAdapter.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Threading.ThreadPool.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Resources.Reader.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Identity.EntityFrameworkCore.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.DependencyModel.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Configuration.Xml.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/System.Data.SqlClient.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Configuration.KeyPerFile.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Logging.Console.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Configuration.Json.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Configuration.Ini.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Configuration.FileExtensions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Threading.Tasks.Dataflow.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Configuration.EnvironmentVariables.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Configuration.Binder.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Diagnostics.Contracts.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.NetworkInformation.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Configuration.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Caching.SqlServer.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Reflection.Emit.Lightweight.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Collections.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Localization.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Caching.Memory.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.IdentityModel.Xml.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Rewrite.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.EntityFrameworkCore.Relational.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.ResponseCompression.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Private.DataContractSerialization.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.CodeAnalysis.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/System.Net.Http.Formatting.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.CodeAnalysis.CSharp.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Diagnostics.Debug.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.WebEncoders.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.DataProtection.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Mvc.Cors.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Primitives.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Logging.TraceSource.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Authentication.OAuth.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.WebUtilities.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.SpaServices.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Runtime.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Cryptography.Internal.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.SignalR.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Cors.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Runtime.Serialization.Json.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Session.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.NodeServices.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Server.Kestrel.Transport.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Resources.ResourceManager.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Server.IISIntegration.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.WebHeaderCollection.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Antiforgery.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Owin.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Text.Encoding.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.SignalR.Common.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Threading.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Reflection.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Reflection.TypeExtensions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.IdentityModel.Tokens.Saml.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Authentication.OpenIdConnect.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Authentication.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Http.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Mvc.ViewFeatures.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.SignalR.Core.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.HttpsPolicy.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Razor.Language.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Http.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.StaticFiles.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Mvc.RazorPages.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Razor.Runtime.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.SpaServices.Extensions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Http.Connections.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Diagnostics.Tracing.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Mvc.Razor.Extensions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.IO.Compression.ZipFile.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.IdentityModel.Logging.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Mvc.Localization.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Cryptography.KeyDerivation.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Buffers.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Mvc.Formatters.Json.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Mvc.ApiExplorer.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Diagnostics.StackTrace.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.ResponseCaching.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Numerics.Vectors.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Globalization.Calendars.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Mvc.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Security.Cryptography.OpenSsl.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.MiddlewareAnalysis.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Logging.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Security.Principal.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.Requests.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.HostFiltering.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Authorization.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Hosting.Server.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.SignalR.Protocols.Json.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Runtime.Numerics.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Mvc.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Runtime.Extensions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Hosting.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.ValueTuple.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Identity.UI.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Diagnostics.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.IO.FileSystem.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Configuration.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Configuration.CommandLine.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Diagnostics.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Text.Encoding.Extensions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Runtime.InteropServices.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.JsonPatch.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Runtime.InteropServices.WindowsRuntime.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.EntityFrameworkCore.Design.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Connections.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Collections.Specialized.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Configuration.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.EntityFrameworkCore.SqlServer.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Http.Connections.Common.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Http.Extensions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Routing.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Mvc.TagHelpers.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.DataProtection.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Authentication.Google.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Server.Kestrel.Https.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.IO.UnmanagedMemoryStream.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Http.Features.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.DotNet.PlatformAbstractions.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/WindowsBase.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Globalization.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Mvc.Core.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Server.HttpSys.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/System.Security.Cryptography.Pkcs.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Authorization.Policy.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.CodeAnalysis.Razor.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.ResponseCaching.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Authentication.JwtBearer.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Razor.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.FileProviders.Embedded.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Private.Xml.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Mvc.Formatters.Xml.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.WebSockets.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Localization.Routing.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.CookiePolicy.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Collections.Immutable.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/netstandard.dll:/Users/pknopf/temp/TestWeb/bin/Debug/netcoreapp2.1/TestWeb.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Authentication.Core.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Authentication.WsFederation.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Server.Kestrel.Core.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Data.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Xml.XPath.XDocument.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Identity.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Hosting.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Server.Kestrel.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/System.Net.WebSockets.WebSocketProtocol.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Linq.Queryable.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Mvc.DataAnnotations.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.Extensions.Logging.Configuration.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.IO.FileSystem.AccessControl.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Html.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.EntityFrameworkCore.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Authentication.MicrosoftAccount.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Runtime.Serialization.Primitives.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Authentication.Facebook.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Web.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.DataProtection.Extensions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.EntityFrameworkCore.InMemory.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Xml.XPath.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.HttpOverrides.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Authentication.Cookies.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Net.NameResolution.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Authentication.Abstractions.dll:/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App/2.1.3/Microsoft.AspNetCore.Identity.UI.Views.dll:/usr/local/share/dotnet/shared/Microsoft.NETCore.App/2.1.3/System.Private.CoreLib.dll:"
  }
}

I believe this is all that I need to fully host a runtime.

What do you guys think?

@pauldotknopf we are in the process of adding a dll host similar to how dotnet works for applications. You can see the initial scenario around Windows COM activiation https://github.com/dotnet/core-setup/pull/4476. The way we are approaching this scenario is to allow people to host the runtime with a runtimeconfig.json and *.deps.json from a predictable path, as opposed to expose how to manually host coreclr. Would your scenario be covered if we exposed the ability to more seamlessly host .NET Core?

cc @AaronRobinsonMSFT

PR dotnet/core-setup#4476 is for Windows only, correct? What about *nix platforms?

That is our starting point, but it will be x-plat. The core of the proposal is having a shared entry point to host the runtime.

Considering so much of the PR is centered around IUnknown, which isn't supported on nix platforms, I'm having trouble seeing where my use-case would fit in. I imagine some simple exported C functions will be proposed later when x-plat is considered.

Let me just re-iterate what I need from the API.

  1. Complete control over the runtime (coreclrhost.h). Not a 1-shot exported C function where you simply pass a .dll path and it executes Program.Main for you. I need to control the life time, invoke delegates, etc.
  2. Support for simple exported C functions. I don't want to manually define IUnknown interfaces and GUID macros for non-windows platforms.

@pauldotknopf The PR in question is definitely related to COM on Windows due to current need, but the long term goal is as @jeffschwMSFT stated. See dotnet/coreclr#19760 which contains a rough outline of what the actual host would be. Observe that COM activation is relegated to a separate compilation unit and is orthogonal to coreclr creation. This is the spirit of what will probably eventually be the host library in core-setup. I can see an obvious benefit for your suggestion and I think it follows with the general approach I am considering.

I need to control the life time, invoke delegates, etc.

This already exists on the API surface - see coreclr_create_delegate in coreclrhost.h

I don't want to manually define IUnknown interfaces and GUID macros for non-windows platforms.

This isn't what that PR is about with respect to hosting. The PR in question is related to how to activate a COM instance from a coreclr instance. @jeffschwMSFT is merely pointing out that in order to activate a COM instance a hosting library (much like the scenario you mention) is needed.

This is the spirit of what will probably eventually be the host library in core-setup. I can see an obvious benefit for your suggestion and I think it follows with the general approach I am considering.

Sounds great! I'll be eagerly awaiting what you guys come up with!

https://twitter.com/runfaster2000/status/1053704090671185920

Is it time for me to look into this issue again to verify that whats implemented meets my requirements?

@pauldotknopf Not yet unfortunately. However, the hosting side is next on my list of things. I was pulled onto getting the basic IDispatch scenario running. Hosting took a back seat, but it is next!

Now that preview 1 is out, should I look into this now?

Sorry to keep pinging, I just want to make sure my use-case is supported when 3.0 finally gets released.

Sorry to keep pinging, I just want to make sure my use-case is supported with 3.0 finally gets released.

@pauldotknopf Please do not stop bugging me! 馃槃 This is definitely important to me. The Preview 1 timeframe for me was focused on native COM server consumption. For Preview 2, my focus will be making some of the dev experience better, but then Preview 3 timeframe will be managed COM servers which will entail addressing the issues you are alluding to with this PR. A co-worker of mine is starting to look into more of these scenarios so that I can consume the CLR as you are and he may get to this work before me.

@vitek-karas Can you please ensure we have captured @pauldotknopf's use case? His PR is very much aligned with what you and I have spoken about and his needs are identical to mine and the problem you have been looking into.

@pauldotknopf I have looked into your implementation more. I like the API surface, but want to make sure what your use case is and how you would anticipate using it. Are you planning on loading coreclr.dll or hostpolicy.dll directly? You mention using coreclrhost.h so I assume coreclr.dll, but want to make sure we are on the same page. Generally this kind of API contract would be contained in the hostpolicy.dll library. The fact that it may be exposed from the coreclr.dll is terribly infuriating story 馃槃

I am almost of the opinion that we should have another header file that exposes a list of documented constants for these properties and a single function that will compute them as desired. This header would be attached to the hostpolicy.dll, which should typically be adjacent to coreclr.dll. Thoughts?

cc @vitek-karas @jkotas

Yes, this new export would be added to hostfxr.dll, named hostfxr_get_clr_properties.

This would return the path to the found coreclr.dll as well as all the properties used to create a .NET Core runtime. I would use this information to load/manage the .NET Core runtime myself (coreclr_initialize, coreclr_create_delegate, coreclr_shutdown, etc). So yeah, I think we are on the same page.

If you are interested, here is my hack since this isn't currently implemented: See this and this. Basically, I invoke my app like a console app, passing it a pointer to a native C function that I convert to a delegate and invoke from .NET, giving control back to the native world, keeping the .NET runtime alive.

But yeah, I don't mind a header file, hostpolicy.h. I'd be willing to help if someone could prototype it for me. This header file would contain these function:

  • hostfxr_get_native_search_directories
  • hostfxr_main
  • hostfxr_main_startupinfo
  • hostfxr_resolve_sdk
  • hostfxr_get_clr_properties - new

Users of the header file would still have to load hostpolicy.dll and grab the exported functions themselves, similarly to coreclrhost.h.

Just want to clarify some things.
hostfxr is a separate library from hostpolicy, the above discussion seems to mix those two.
Neither is actually easy to get to. hostxr lives in the shared location but the rule is to use the latest version, so your code would have to be able to parse versions and find the latest.
hostpolicy is even more complex since your code would have to be able to determine which frameworks to use. Also since hostpolicy lives next to coreclr - so there's really no point in returning path to coreclr from hostpolicy itself.

I know that @AaronRobinsonMSFT 's COM scenario is planning to introduce a new global "entry point", basically just like there's dotnet.exe there would be something like dotnet.dll (probably different name) which would act as the COM entry point. This component would act basically the same as dotnet.exe does - that is it finds the right hostfxr and let it do all the work.

@pauldotknopf in your scenario, what is the main reason you want to host CoreCLR yourself? I'm not questioning the need, I'm just curious what is the scenario. COM above is one such scenario, what is yours?

As for solution:

Exposing this funxtion on hostfxr definitely makes sense since its functionality would start there. But it still means one has to find hostfxr itself which is not super simple.

We could expose a new export on the dotnet.dll which would return the path to the hostfxr. That way it would be relatively straightforward to write code which behaves like the host, but still have control over what's being done when.

Alternatively we could provide an export like the proposed one but from the dotnet.dll directly.

In terms of the API design, I don't like the API returning a JSON. It basically means that the caller must have a JSON parser. Given that the caller is C++ (or potentially some other non-.NET language) it might be a high price to pay.
It would be cleaner to define a structure (we could version it, so that it's extensible in the future) and return that. This comes with memory allocation issues unfortunately, but that can be solved using the same techniques that other APIs on hostfxr already use, that is have the caller provide a callback which the library calls and provides the information. It's up to the callback to make a copy of that information (using whatever memory allocation mechanisms it wants).

I need this functionality for my .NET Core GUI library, Qml.Net.

I need to create a .NET runtime from C++ and invoke classes/delegates. This is so that my native code could can call C#, which would then give managed (pinned) c-style callbacks back to native code, that then allows Qml.Net to fully interoperate between QML and .NET. See this.

My native code would look something like this (pseudo-code):

void main() {
    DotnetRuntime runtime = buildRuntime()
    /*wire up Qml.Net native callbacks*/
    runtime.callStaticMethod("Qml.Net.Interop, Qml.Net" /*class*/, "Initialize" /*method*/)
    //  Run QML engine, keeping the .NET Core runtime alive for the duration of the app.
    QApplication app
    return app.exec()
}

Then, within my QML application, I can create and work with .NET objects all-day-long.

import Net
Item {
    Component.onCompleted: {
        var netObject = Net.createObject("SomeClass, SomeLib")
        console.log(netObject.sum(4, 10))
    }
}

I was only able to acheive this via a hacky method.
What I did was find a potential hostfxr.dll library using some parsing of the versions directory (as you guessed I would need to do) here.

I then load that lib and export the hostfxr_main method to start a .NET runtime as if it were a console application.

The question the becomes: How do I keep the .NET runtime alive indefinately while I transfer control back to native code to begin an event loop for Qt/QML?

Well, my DotNet.Program.Main expects certain arguements, which are pointer addresses that I convert to .NET delegates to invoke. When invoked, native code will pick back up and continue from there, ensuring that the .NET runtime is alive and well for the duration.

You can see the .NET code which catches the native invocation of hostfxr_main with the expected arguments and invokes the delegate here.

You can see my hack in full display as a runnable example here.

As you can see though, if .NET Core had the methods that you are describing, I wouldn't need to pass things back and forth in this somewhat brittle approach.

As for your comments:

Exposing this funxtion on hostfxr definitely makes sense since its functionality would start there. But it still means one has to find hostfxr itself which is not super simple.

Exactly. As you can see in my CoreHost.cpp, I do exactly that.

We could expose a new export on the dotnet.dll which would return the path to the hostfxr. That way it would be relatively straightforward to write code which behaves like the host, but still have control over what's being done when.

Yes! As long as hostfxr.dll can give me everything I'd need to call coreclr.dll myself, which I assume will always exist next to hostfxr.dll.

Alternatively we could provide an export like the proposed one but from the dotnet.dll directly.

I like this idea too, but I'd still need to get the path of the coreclr.dll to invoke and run it. I guess adding hostfxr_get_clr_properties right on dotnet.dll would elimate one more library I'd have to manually dllopen, leaving just the coreclr.dll.

In terms of the API design, I don't like the API returning a JSON. It basically means that the caller must have a JSON parser.

Agreed.

In the end, all the solutions you proposed worked.

Regardless of the approach, I think you have a pretty good grasp on what I would like to see for usage in Qml.Net.

Is there something I can do here? If I could get some guidance on an approach that is acceptable, I could take a stab at it.

Thanks for offer @pauldotknopf. This is an intermediate building block of a larger scenario. Some of the core issues that I have seen in this area can be fit within two categories: 1) enable an easy way to locate the right runtime (including version) and 2) start the runtime. Adding a hostfxr convenience API to start the runtime is part of this broader work. There are two high level approaches (both with pros and cons) expose such an API that returns a handle to a loaded and started coreclr, or expose convenience APIs for the mechanisms that Coreclr provides (create delegate, etc.).

The best way to help is to create an api proposal with the broader scenario in mind.

@pauldotknopf We in the middle of finalizing a plan for this and should have something to share soon. I realize this has been going on for a while now, appreciate your patience.

@pauldotknopf please take a look at dotnet/core-setup#5336 .
For your scenario I think that you would use the nethost and the nethost_load_assembly_method to get a function pointer to a managed static method (or many) and then using those establish the communication between the native and managed parts.

Please note that as designed, the managed components loaded using this API are fully isolated (don't know about each other). So if you only have one managed component, it doesn't matter. If you have many and they need to know about each other, a wrapping managed component would have to be added to the implementation.

@vitek-karas, this looks like it would work for me! I'm excited to try it out.

@pauldotknopf As we work through the details of dotnet/core-setup#5336, we are trying to decide the requirements for the entry point in the managed static method.

When loading managed components, we want to load and isolate them into there own AssemblyLoadContext. Then we will need to allow the native code to call into an initial entry point into the managed component.

The current proposal for the entry point call signature is:

C# delegate int NativeHostedEntryPoint(IntPtr args, int sizeBytes); // A span of memory...

We wanted to know if this was sufficient for a minimum viable product for your use case.

The static entry point in managed .NET would have to be that particular signature? So this would work?

```c#
public static class NetStaticClass
{
public static int StaticMethod(IntPtr args, int sizeBytes)
{
// .NET method...
}
}

Hopefully, it wouldn't have to be specifically a ```NativeHostedEntryPoint``` delegate. Otherwise, I'd imagine I'd have to have a ```netcoreapp3.0``` target for my lib, instead of just ```netstandard2.0```.

What about ```IntPtr *args```? So this would require ```unsafe``` compilation? Could it be a ```ref IntPtr args```? I'm confused on the need for ```*/ref``` at all though, because I imagine the C call would be something like:

```C
MyStruct value;
invoke_static_net_method(some_handle_to_runtime /*not sure, not important*/, "NetStaticClass.StaticMethod", &value, sizeof(MyStruct));

I guess I'm not sure what the need for the double pointer in the .NET delegate is.

Also, no marshalling? This is fine for me, just being clear.

So this would work?

That is exactly what I was proposing.

no marshalling

The current proposal includes no automatic marshalling.

not sure what the need for the double pointer

Typo. Edited above.

C call would be something like:

using ManagedEntryPointFunctionPtr = int(*)(void*, uint32_t);

ManagedEntryPointFunctionPtr myEntryPoint;
int result = nethost_get_runtime_delegate(nethost_context, 
                                          assemblyPath, // Fully qualified path to assembly
                                          typeName,   // "<namespace>.NetStaticClass"
                                          methodName, // "StaticMethod"
                                          & myEntryPoint);

if (nethost_success(result))
{
    myEntryPoint(&value, (uint32_t)sizeof(MyStruct))
}

The nethost_get_runtime_delegate(...) call would

  • load a component such that all it dependencies were resolved using its *.deps.json file (using .NET Core 3.0's AssemblyDependencyResolver). assemblyPath would be loaded into an isolated AssemblyLoadContext. It would be shared by all nethost_get_runtime_delegate calls using the same assemblyPath
  • Find the type
  • Find the static method
  • Return a native function pointer to the method. the entry point can be called more than once. More than one entry point for the same assemblyPath is allowed.

This all works for me :)

cc @elinor-fung

@elinor-fung does our native hosting solution solve the problems described in this issue?

We now have an API on hostfxr to get a delegate for specific runtime functionality: https://github.com/dotnet/core-setup/blob/master/Documentation/design-docs/native-hosting.md#getting-a-delegate-for-runtime-functionality.

One of those options is a delegate for loading a managed component and getting a function pointer to a method in it.

Usage would look something like:

using load_assembly_and_get_function_pointer_fn = int (STDMETHODCALLTYPE *)(
    const char_t * assembly_path,
    const char_t * type_name,
    const char_t * method_name,
    const char_t * delegate_type_name,
    void * reserved,
    void ** delegate);

hostfxr_handle handle;
hostfxr_initialize_for_runtime_config(config_path, nullptr, &handle);

load_assembly_and_get_function_pointer_fn runtime_delegate = nullptr;
hostfxr_get_runtime_delegate(
    host_context_handle,
    hostfxr_delegate_type::load_assembly_and_get_function_pointer,
    (void **)&runtime_delegate);

using managed_entry_point_fn = int (STDMETHODCALLTYPE *)(void *arg, int argSize);

managed_entry_point_fn entry_point = nullptr;
runtime_delegate(assembly_path,
                 type_name,
                 method_name,
                 nullptr,
                 nullptr,
                 (void **)&entry_point);

ArgStruct arg;
entry_point(&arg, sizeof(ArgStruct));

hostfxr_close(handle);

The managed entry point signature is by default (when delegate_type_name is nulltpr) what was mentioned previously, e.g the managed component could be:
C# public class Component { public static int EntryPoint(IntPtr arg, int size) { ... } }

As @elinor-fung mentioned. This is resolved in tip and is expected to be included in ,NET Core 3.0 preview6. Closing.

Was this page helpful?
0 / 5 - 0 ratings