Back to Dotnet

Hosting layer error and exit codes

docs/design/features/host-error-codes.md

11.0.10016.2 KB
Original Source

Hosting layer error and exit codes

This document lists all the values returned as special exit codes when running dotnet.exe or apphost or returned by the hosting APIs (hostfxr, hostpolicy and nethost). Those exit codes are also specified in signed 32-bit form (what you would see if you run echo %ERRORLEVEL% on Winodws) and in 8-bit form (what you would see if you run echo $? on Linux). Note that the exit code returned by running an application via dotnet.exe or apphost can either be one of the below values or the exit code of the managed application itself.

Success error/exit codes

NameValueValue (signed, 32-bit)Value (8-bit)Description
Success0x0000000000Operation was successful.
Success_HostAlreadyInitialized0x0000000111Initialization was successful, but another host context is already initialized, so the returned context is "secondary". The requested context was otherwise fully compatible with the already initialized context. This is returned by hostfxr_initialize_for_runtime_config if it's called when the host is already initialized in the process. Comes from corehost_initialize in hostpolicy.
Success_DifferentRuntimeProperties0x0000000222Initialization was successful, but another host context is already initialized and the requested context specified runtime properties which are not the same (either in value or in presence) to the already initialized context. This is returned by hostfxr_initialize_for_runtime_config if it's called when the host is already initialized in the process. Comes from corehost_initialize in hostpolicy.

Failure error/exit codes

NameValueValue (signed, 32-bit)Value (8-bit)Description
InvalidArgFailure0x80008081-2147450751129One or more arguments are invalid.
CoreHostLibLoadFailure0x80008082-2147450750130Failed to load a hosting component. If loading a hosting component via LoadLibrary/dlopen fails, this error code is returned. The most common case for this failure is if the 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).
CoreHostLibMissingFailure0x80008083-2147450749131One of the hosting components is missing. Typically when the hostfxr, hostpolicy or coreclr dynamic libraries are not present in the expected locations. Probably means corrupted or incomplete installation.
CoreHostEntryPointFailure0x80008084-2147450748132One of the hosting components is missing a required entry point.
CoreHostCurHostFindFailure0x80008085-2147450747133Failed to get the path of the current hosting component and determine the .NET installation location. 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.
CoreClrResolveFailure0x80008087-2147450745135The coreclr library could not be found. The hosting layer (hostpolicy) looks for coreclr 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.
CoreClrBindFailure0x80008088-2147450744136Failed to load the coreclr library or finding one of the required entry points.
CoreClrInitFailure0x80008089-2147450743137Call to coreclr_initialize failed. The actual error returned by coreclr is reported in the error message.
CoreClrExeFailure0x8000808a-2147450742138Call 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.
ResolverInitFailure0x8000808b-2147450741139Initialization of the hostpolicy dependency resolver failed. This can be: <ul><li> One of the frameworks or the app is missing a required .deps.json file. </li><li> One of the .deps.json files is invalid (invalid JSON, or missing required properties and so on). </li></ul>
ResolverResolveFailure0x8000808c-2147450740140Resolution 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).
LibHostInitFailure0x8000808e-2147450738142Initialization 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.
LibHostSdkFindFailure0x80008091-2147450735145Failed 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.
LibHostInvalidArgs0x80008092-2147450734146Arguments to hostpolicy are invalid. This is used in various separate places in hostpolicy, but in all cases it means the component calling hostpolicy did something wrong: <ul><li> 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. </li><li> hostpolicy context's get_delegate - if the requested delegate enum value is not recognized. Again this would mean hostfxr passed the wrong value. </li><li> corehost_main_with_output_buffer - if hostpolicy was initialized with an unknown host command. This would indicate incompatibility between the hostfxr and hostpolicy. In reality this should pretty much never happen. </li><li> 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. </li></ul>
InvalidConfigFile0x80008093-2147450733147The .runtimeconfig.json file is invalid. The reasons for this failure can be among these: <ul><li> Failure to read from the file </li><li> Invalid JSON </li><li> Invalid value for a property (for example number for property which requires a string) </li><li> Missing required property </li><li> Other inconsistencies (for example rollForward and applyPatches are not allowed to be specified in the same config file) </li><li> Any of the above failures reading the .runtimecofig.dev.json file </li><li> 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. </li></ul>
AppArgNotRunnable0x80008094-2147450732148Used internally when the command line for dotnet.exe doesn't contain path to the application to run. In such case the command line is considered to be a CLI/SDK command. This error code should never be returned to external caller.
AppHostExeNotBoundFailure0x80008095-2147450731149apphost failed to determine which application to run. This can mean: <ul><li> 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) </li><li> The apphost is a bundle (single-file exe) and it failed to extract correctly. </li><li>The apphost binary has been imprinted with invalid .NET search options</li></ul>
FrameworkMissingFailure0x80008096-2147450730150Failed to finding 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.
HostApiFailed0x80008097-2147450729151Host command failed. Returned by hostfxr_get_native_search_directories if the hostpolicy could not calculate the NATIVE_DLL_SEARCH_DIRECTORIES.
HostApiBufferTooSmall0x80008098-2147450728152Buffer provided to a host API is too small to fit the requested value. Can be returned from: <ul><li> hostfxr_get_runtime_properties </li><li> hostfxr_get_native_search_directories </li><li> get_hostfxr_path </li></ul>
AppPathFindFailure0x8000809a-2147450726154Application path imprinted in apphost doesn't exist. This would happen if the app is built with an executable (the apphost) and the main app.dll is missing.
SdkResolveFailure0x8000809b-2147450725155Failed to find the requested SDK. This happens in the hostfxr when an SDK (also called CLI) command is used with dotnet or when calling the hostfxr_resolve_sdk2 API. 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.
FrameworkCompatFailure0x8000809c-2147450724156Application has multiple references to the same framework which are not compatible - found during processing of .runtimeconfig.json. 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.
FrameworkCompatRetry0x8000809d-2147450723157Error used internally if the processing of framework references from .runtimeconfig.json reached a point where it needs to reprocess another already processed framework reference. If this error is returned to the external caller, it would mean there's a bug in the framework resolution algorithm.
BundleExtractionFailure0x8000809f-2147450721159Error extracting single-file bundle. This is used in case of any error related to the bundle itself. Typically would mean a corrupted bundle.
BundleExtractionIOError0x800080a0-2147450720160Error reading or writing files during single-file bundle extraction.
LibHostDuplicateProperty0x800080a1-2147450719161The application's .runtimeconfig.json contains a runtime property which is 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.
HostApiUnsupportedVersion0x800080a2-2147450718162Feature which requires certain version of the hosting layer 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.
HostInvalidState0x800080a3-2147450717163Current state is incompatible with the requested operation - returned by the hosting APIs in hostfxr. 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.
HostPropertyNotFound0x800080a4-2147450716164Property requested by hostfxr_get_runtime_property_value doesn't exist.
HostIncompatibleConfig0x800080a5-2147450715165Host configuration is incompatible with existing host context - returned by hostfxr_initialize_for_runtime_config. 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.
HostApiUnsupportedScenario0x800080a6-2147450714166Hosting API does not support the requested scenario. Returned by hostfxr_get_runtime_delegate when hostfxr doesn't support requesting the given delegate type using the given context.
HostFeatureDisabled0x800080a7-2147450713167Support for a requested feature is disabled. Returned by hostfxr_get_runtime_delegate when managed feature support for native host is disabled.