pub struct HostfxrContext<I> { /* private fields */ }
Available on crate feature netcore3_0 only.
Expand description

State which hostfxr creates and maintains and represents a logical operation on the hosting components.

Implementations§

source§

impl<I> HostfxrContext<I>

source

pub unsafe fn from_handle( handle: HostfxrHandle, hostfxr: Hostfxr, is_primary: bool ) -> Self

Creates a new context from the given handle.

§Safety

The context handle has to be match the context type I. If the context was initialized using initialize_for_dotnet_command_line I has to be InitializedForCommandLine. If the context was initialized using initialize_for_runtime_config I has to be InitializedForRuntimeConfig.

source

pub const fn handle(&self) -> HostfxrHandle

Gets the underlying handle to the hostfxr context.

source

pub fn into_handle(self) -> HostfxrHandle

Gets the underlying handle to the hostfxr context and consume this context.

source

pub const fn is_primary(&self) -> bool

Gets whether the context is the primary hostfxr context. There can only be a single primary context in a process.

§Note

https://github.com/dotnet/core-setup/blob/master/Documentation/design-docs/native-hosting.md#synchronization

source

pub fn get_runtime_delegate( &self, type: hostfxr_delegate_type ) -> Result<RawFunctionPtr, HostingError>

Gets a typed delegate from the currently loaded CoreCLR or from a newly created one. You propably want to use get_delegate_loader or get_delegate_loader_for_assembly instead of this function if you want to load function pointers.

§Remarks

If the context was initialized using initialize_for_runtime_config, then all delegate types are supported. If it was initialized using initialize_for_dotnet_command_line, then only the following delegate types are currently supported:

source

pub fn get_delegate_loader(&self) -> Result<DelegateLoader, HostingError>

Gets a delegate loader for loading an assembly and contained function pointers.

source

pub fn get_delegate_loader_for_assembly( &self, assembly_path: impl Into<PdCString> ) -> Result<AssemblyDelegateLoader, HostingError>

Gets a delegate loader for loading function pointers of the assembly with the given path. The assembly will be loaded lazily when the first function pointer is loaded.

source

pub fn load_assembly_from_path( &self, assembly_path: impl AsRef<PdCStr> ) -> Result<(), HostingError>

Loads the specified assembly in the default load context from the given path. It uses AssemblyDependencyResolver to register additional dependency resolution for the load context. Function pointers to methods in the assembly can then be loaded using a DelegateLoader.

source

pub fn load_assembly_from_bytes( &self, assembly_bytes: impl AsRef<[u8]>, symbols_bytes: impl AsRef<[u8]> ) -> Result<(), HostingError>

Loads the specified assembly in the default load context from the given buffers. It does not provide a mechanism for registering additional dependency resolution, as mechanisms like .deps.json and AssemblyDependencyResolver are file-based. Dependencies can be pre-loaded (for example, via a previous call to this function) or the specified assembly can explicitly register its own resolution logic (for example, via the AssemblyLoadContext.Resolving event). It uses AssemblyDependencyResolver to register additional dependency resolution for the load context. Function pointers to methods in the assembly can then be loaded using a DelegateLoader.

source

pub fn close(self) -> Result<HostingSuccess, HostingError>

Closes an initialized host context. This method is automatically called on drop, but can be explicitely called to handle errors during closing.

source§

impl HostfxrContext<InitializedForCommandLine>

source

pub fn run_app(self) -> AppOrHostingResult

Load the dotnet runtime and run the application.

§Return value

If the app was successfully run, the exit code of the application. Otherwise, the error code result.

source§

impl<I> HostfxrContext<I>

source

pub fn get_runtime_property_value( &self, name: impl AsRef<PdCStr> ) -> Result<&PdCStr, HostingError>

Gets the runtime property value for the given key of this host context.

source

pub fn set_runtime_property_value( &mut self, name: impl AsRef<PdCStr>, value: impl AsRef<PdCStr> ) -> Result<(), HostingError>

Sets the value of a runtime property for this host context.

source

pub fn remove_runtime_property_value( &mut self, name: impl AsRef<PdCStr> ) -> Result<(), HostingError>

Remove a runtime property for this host context.

source

pub fn runtime_properties( &self ) -> Result<HashMap<&PdCStr, &PdCStr>, HostingError>

Get all runtime properties for this host context.

Trait Implementations§

source§

impl<I> Debug for HostfxrContext<I>

source§

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

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

impl<I> DestructDrop for HostfxrContext<I>

source§

fn destruct_drop(self)

Consume self without dropping it while dropping all of its contents normally.
source§

impl<I> Drop for HostfxrContext<I>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<I> Send for HostfxrContext<I>

Auto Trait Implementations§

§

impl<I> !RefUnwindSafe for HostfxrContext<I>

§

impl<I> !Sync for HostfxrContext<I>

§

impl<I> Unpin for HostfxrContext<I>
where I: Unpin,

§

impl<I> UnwindSafe for HostfxrContext<I>
where I: UnwindSafe,

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, 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.