Enum netcorehost::error::HostingError
source · pub enum HostingError {
Show 35 variants
InvalidArgFailure,
CoreHostLibLoadFailure,
CoreHostLibMissingFailure,
CoreHostEntryPointFailure,
CoreHostCurHostFindFailure,
CoreClrResolveFailure,
CoreClrBindFailure,
CoreClrInitFailure,
CoreClrExeFailure,
ResolverInitFailure,
ResolverResolveFailure,
LibHostCurExeFindFailure,
LibHostInitFailure,
LibHostSdkFindFailure,
LibHostInvalidArgs,
InvalidConfigFile,
AppHostExeNotBoundFailure,
FrameworkMissingFailure,
HostApiFailed,
HostApiBufferTooSmall,
LibHostUnknownCommand,
LibHostAppRootFindFailure,
SdkResolverResolveFailure,
FrameworkCompatFailure,
AppHostExeNotBundle,
BundleExtractionFailure,
BundleExtractionIOError,
LibHostDuplicateProperty,
HostApiUnsupportedVersion,
HostInvalidState,
HostPropertyNotFound,
CoreHostIncompatibleConfig,
HostApiUnsupportedScenario,
HostFeatureDisabled,
Unknown(u32),
// some variants omitted
}
Expand description
Error codes returned by the hosting APIs from hostfxr
, hostpolicy
and nethost
.
Source: https://github.com/dotnet/runtime/blob/main/docs/design/features/host-error-codes.md
Variants§
InvalidArgFailure
One of the specified arguments for the operation is invalid.
CoreHostLibLoadFailure
There was a failure loading a dependent library.
If any of the hosting components calls LoadLibrary
/dlopen
on a dependent library and the call fails, this error code is returned.
The most common case for this failure is if the dependent library is missing some of its dependencies (for example the necessary CRT is missing on the machine), likely corrupt or incomplete install.
This error code is also returned from corehost_resolve_component_dependencies
if it’s called on a hostpolicy
which has not been initialized via the hosting layer.
This would typically happen if coreclr
is loaded directly without the hosting layer and then AssemblyDependencyResolver
is used (which is an unsupported scenario).
CoreHostLibMissingFailure
One of the dependent libraries is missing.
Typically when the hostfxr
, hostpolicy
or coreclr
dynamic libraries are not present in the expected locations.
Probably means corrupted or incomplete installation.
CoreHostEntryPointFailure
One of the dependent libraries is missing a required entry point.
CoreHostCurHostFindFailure
If the hosting component is trying to use the path to the current module (the hosting component itself) and from it deduce the location of the installation.
Either the location of the current module could not be determined (some weird OS call failure) or the location is not in the right place relative to other expected components.
For example the hostfxr
may look at its location and try to deduce the location of the shared
folder with the framework from it.
It assumes the typical install layout on disk. If this doesn’t work, this error will be returned.
CoreClrResolveFailure
If the coreclr
library could not be found.
The hosting layer (hostpolicy
) looks for coreclr
library either next to the app itself (for self-contained) or in the root framework (for framework-dependent).
This search can be done purely by looking at disk or more commonly by looking into the respective .deps.json
.
If the coreclr
library is missing in .deps.json
or it’s there but doesn’t exist on disk, this error is returned.
CoreClrBindFailure
The loaded coreclr
library doesn’t have one of the required entry points.
CoreClrInitFailure
The call to coreclr_initialize
failed.
The actual error returned by coreclr
is reported in the error message.
CoreClrExeFailure
The call to coreclr_execute_assembly
failed.
Note that this does not mean anything about the app’s exit code, this failure occurs if coreclr
failed to run the app itself.
ResolverInitFailure
Initialization of the hostpolicy
dependency resolver failed.
This can be:
- One of the frameworks or the app is missing a required
.deps.json
file. - One of the
.deps.json
files is invalid (invalid JSON, or missing required properties and so on).
ResolverResolveFailure
Resolution of dependencies in hostpolicy
failed.
This can mean many different things, but in general one of the processed .deps.json
contains entry for a file which could not found, or its resolution failed for some other reason (conflict for example).
LibHostCurExeFindFailure
Failure to determine the location of the current executable. The hosting layer uses the current executable path to deduce the install location in some cases. If this path can’t be obtained (OS call fails, or the returned path doesn’t exist), this error is returned.
LibHostInitFailure
Initialization of the hostpolicy
library failed.
The corehost_load
method takes a structure with lot of initialization parameters.
If the version of this structure doesn’t match the expected value, this error code is returned.
This would in general mean incompatibility between the hostfxr
and hostpolicy
, which should really only happen if somehow a newer hostpolicy
is used by older hostfxr
.
This typically means corrupted installation.
LibHostSdkFindFailure
Failure to find the requested SDK.
This happens in the hostfxr
when an SDK (also called CLI) command is used with dotnet
.
In this case the hosting layer tries to find an installed .NET SDK to run the command on.
The search is based on deduced install location and on the requested version from potential global.json
file.
If either no matching SDK version can be found, or that version exists, but it’s missing the dotnet.dll
file, this error code is returned.
LibHostInvalidArgs
Arguments to hostpolicy
are invalid.
This is used in three unrelated places in the hostpolicy
, but in all cases it means the component calling hostpolicy
did something wrong:
- Command line arguments for the app - the failure would typically mean that wrong argument was passed or such.
For example if the application main assembly is not specified on the command line.
On its own this should not happen as
hostfxr
should have parsed and validated all command line arguments. hostpolicy
context’sget_delegate
- if the requested delegate enum value is not recognized. Again this would meanhostfxr
passed the wrong value.corehost_resolve_component_dependencies
- if something went wrong initializinghostpolicy
internal structures. Would happen for example when thecomponent_main_assembly_path
argument is wrong.
InvalidConfigFile
The .runtimeconfig.json
file is invalid.
The reasons for this failure can be among these:
- Failure to read from the file
- Invalid JSON
- Invalid value for a property (for example number for property which requires a string)
- Missing required property
- Other inconsistencies (for example
rollForward
andapplyPatches
are not allowed to be specified in the same config file) - Any of the above failures reading the
.runtimecofig.dev.json
file - Self-contained
.runtimeconfig.json
used inhostfxr_initialize_for_runtime_config
. Note that missing.runtimconfig.json
is not an error (means self-contained app). This error code is also used when there is a problem reading the CLSID map file incomhost
.
AppHostExeNotBoundFailure
apphost
failed to determine which application to run.
This can mean:
- The
apphost
binary has not been imprinted with the path to the app to run (so freshly builtapphost.exe
from the branch will fail to run like this) - The
apphost
is a bundle (single-file exe) and it failed to extract correctly.
FrameworkMissingFailure
It was not possible to find a compatible framework version.
This originates in hostfxr
(resolve_framework_reference
) and means that the app specified a reference to a framework in its .runtimeconfig.json
which could not be resolved.
The failure to resolve can mean that no such framework is available on the disk, or that the available frameworks don’t match the minimum version specified or that the roll forward options specified excluded all available frameworks.
Typically this would be used if a 3.0 app is trying to run on a machine which has no 3.0 installed.
It would also be used for example if a 32bit 3.0 app is running on a machine which has 3.0 installed but only for 64bit.
HostApiFailed
Returned by hostfxr_get_native_search_directories
if the hostpolicy
could not calculate the NATIVE_DLL_SEARCH_DIRECTORIES
.
HostApiBufferTooSmall
Returned when the buffer specified to an API is not big enough to fit the requested value. Can be returned from:
hostfxr_get_runtime_properties
hostfxr_get_native_search_directories
get_hostfxr_path
LibHostUnknownCommand
Returned by hostpolicy
if the corehost_main_with_output_buffer
is called with unsupported host command.
This error code means there is incompatibility between the hostfxr
and hostpolicy
.
In reality this should pretty much never happen.
LibHostAppRootFindFailure
Returned by apphost
if the imprinted application path doesn’t exist.
This would happen if the app is built with an executable (the apphost
) and the main app.dll
is missing.
SdkResolverResolveFailure
Returned from hostfxr_resolve_sdk2
when it fails to find matching SDK.
Similar to LibHostSdkFindFailure
but only used in the hostfxr_resolve_sdk2
.
FrameworkCompatFailure
During processing of .runtimeconfig.json
there were two framework references to the same framework which were not compatible.
This can happen if the app specified a framework reference to a lower-level framework which is also specified by a higher-level framework which is also used by the app.
For example, this would happen if the app referenced Microsoft.AspNet.App
version 2.0 and Microsoft.NETCore.App
version 3.0. In such case the Microsoft.AspNet.App
has .runtimeconfig.json
which also references Microsoft.NETCore.App
but it only allows versions 2.0 up to 2.9 (via roll forward options).
So the version 3.0 requested by the app is incompatible.
AppHostExeNotBundle
Error reading the bundle footer metadata from a single-file apphost
.
This would mean a corrupted apphost
.
BundleExtractionFailure
Error extracting single-file apphost
bundle.
This is used in case of any error related to the bundle itself.
Typically would mean a corrupted bundle.
BundleExtractionIOError
Error reading or writing files during single-file apphost
bundle extraction.
LibHostDuplicateProperty
The .runtimeconfig.json
specified by the app contains a runtime property which is also produced by the hosting layer.
For example if the .runtimeconfig.json
would specify a property TRUSTED_PLATFORM_ROOTS
, this error code would be returned.
It is not allowed to specify properties which are otherwise populated by the hosting layer (hostpolicy
) as there is not good way to resolve such conflicts.
HostApiUnsupportedVersion
Feature which requires certain version of the hosting layer binaries was used on a version which doesn’t support it.
For example if COM component specified to run on 2.0 Microsoft.NETCore.App
- as that contains older version of hostpolicy
which doesn’t support the necessary features to provide COM services.
HostInvalidState
Error code returned by the hosting APIs in hostfxr
if the current state is incompatible with the requested operation.
There are many such cases, please refer to the documentation of the hosting APIs for details.
For example if hostfxr_get_runtime_property_value
is called with the host_context_handle
nullptr
(meaning get property from the active runtime) but there’s no active runtime in the process.
HostPropertyNotFound
Property requested by hostfxr_get_runtime_property_value
doesn’t exist.
CoreHostIncompatibleConfig
Error returned by hostfxr_initialize_for_runtime_config
if the component being initialized requires framework which is not available or incompatible with the frameworks loaded by the runtime already in the process.
For example trying to load a component which requires 3.0 into a process which is already running a 2.0 runtime.
HostApiUnsupportedScenario
Error returned by hostfxr_get_runtime_delegate
when hostfxr
doesn’t currently support requesting the given delegate type using the given context.
HostFeatureDisabled
Error returned by hostfxr_get_runtime_delegate
when managed feature support for native host is disabled.
Unknown(u32)
Unknown error status code.
Implementations§
source§impl HostingError
impl HostingError
sourcepub const fn from_status_code(code: u32) -> Self
pub const fn from_status_code(code: u32) -> Self
Creates a new HostingError
from the raw status code.
sourcepub const fn known_from_status_code(code: u32) -> Result<Self, u32>
pub const fn known_from_status_code(code: u32) -> Result<Self, u32>
Tries to create a new HostingError
from the raw status code if it is known.
Otherwise returns the given value as an Err
.
sourcepub const fn is_known(&self) -> bool
pub const fn is_known(&self) -> bool
Returns whether the status code of this error has a known meaning.
sourcepub const fn is_unknown(&self) -> bool
pub const fn is_unknown(&self) -> bool
Returns whether the status code of this error has a unknown meaning.
Trait Implementations§
source§impl Clone for HostingError
impl Clone for HostingError
source§fn clone(&self) -> HostingError
fn clone(&self) -> HostingError
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for HostingError
impl Debug for HostingError
source§impl Display for HostingError
impl Display for HostingError
source§impl Error for HostingError
impl Error for HostingError
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
source§impl From<HostingError> for Error
impl From<HostingError> for Error
source§fn from(source: HostingError) -> Self
fn from(source: HostingError) -> Self
source§impl From<HostingError> for GetManagedFunctionError
impl From<HostingError> for GetManagedFunctionError
source§fn from(source: HostingError) -> Self
fn from(source: HostingError) -> Self
source§impl From<HostingError> for HostingResult
impl From<HostingError> for HostingResult
source§fn from(error: HostingError) -> Self
fn from(error: HostingError) -> Self
source§impl From<HostingError> for LoadHostfxrError
impl From<HostingError> for LoadHostfxrError
source§fn from(source: HostingError) -> Self
fn from(source: HostingError) -> Self
source§impl From<HostingError> for u32
impl From<HostingError> for u32
source§fn from(code: HostingError) -> Self
fn from(code: HostingError) -> Self
source§impl Hash for HostingError
impl Hash for HostingError
source§impl Ord for HostingError
impl Ord for HostingError
source§fn cmp(&self, other: &HostingError) -> Ordering
fn cmp(&self, other: &HostingError) -> Ordering
1.21.0 · source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
source§impl PartialEq for HostingError
impl PartialEq for HostingError
source§fn eq(&self, other: &HostingError) -> bool
fn eq(&self, other: &HostingError) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PartialOrd for HostingError
impl PartialOrd for HostingError
source§fn partial_cmp(&self, other: &HostingError) -> Option<Ordering>
fn partial_cmp(&self, other: &HostingError) -> Option<Ordering>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more