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’s get_delegate - if the requested delegate enum value is not recognized. Again this would mean hostfxr passed the wrong value.
  • corehost_resolve_component_dependencies - if something went wrong initializing hostpolicy internal structures. Would happen for example when the component_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 and applyPatches 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 in hostfxr_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 in comhost.
§

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 built apphost.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

source

pub const fn from_status_code(code: u32) -> Self

Creates a new HostingError from the raw status code.

source

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.

source

pub const fn value(&self) -> u32

Returns the underlying status code value.

source

pub const fn is_known(&self) -> bool

Returns whether the status code of this error has a known meaning.

source

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

source§

fn clone(&self) -> HostingError

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for HostingError

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Display for HostingError

source§

fn fmt(&self, _derive_more_display_formatter: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Error for HostingError

1.30.0 · source§

fn source(&self) -> Option<&(dyn Error + 'static)>

The lower-level source of this error, if any. Read more
1.0.0 · source§

fn description(&self) -> &str

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more
source§

impl From<HostingError> for Error

source§

fn from(source: HostingError) -> Self

Converts to this type from the input type.
source§

impl From<HostingError> for GetManagedFunctionError

source§

fn from(source: HostingError) -> Self

Converts to this type from the input type.
source§

impl From<HostingError> for HostingResult

source§

fn from(error: HostingError) -> Self

Converts to this type from the input type.
source§

impl From<HostingError> for LoadHostfxrError

source§

fn from(source: HostingError) -> Self

Converts to this type from the input type.
source§

impl From<HostingError> for u32

source§

fn from(code: HostingError) -> Self

Converts to this type from the input type.
source§

impl Hash for HostingError

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for HostingError

source§

fn cmp(&self, other: &HostingError) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for HostingError

source§

fn eq(&self, other: &HostingError) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for HostingError

source§

fn partial_cmp(&self, other: &HostingError) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl TryFrom<u32> for HostingError

§

type Error = u32

The type returned in the event of a conversion error.
source§

fn try_from(code: u32) -> Result<Self, Self::Error>

Performs the conversion.
source§

impl Copy for HostingError

source§

impl Eq for HostingError

source§

impl StructuralPartialEq for HostingError

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.