Евгений Напрягло ".NET Framework Hosting API Overview"

Post on 05-Apr-2017

127 views 2 download

transcript

.NET CLR Hosting APIEvgen NapryagloIntetics

1. Runtime Customizations

Runtime

AssemblyLoading

PolicyManagement

HostProtection

MemoryManagement

GarbageCollection

I/O Completion

CLREvents

TaskManagement

SynchronizationManagement

Thread PoolManagement

Application Host – Native Environment

.NET Application Environment

Objectives• Monitoring• Diagnostics

• Customization• Restriction

• Integration• Extensibility

Development Operations

Product Development

Enterprise Integration

2. Execution & State Monitoring

ProfilingAPI

DebuggingAPI

CLR Hosting

Host

Runtime

.NET CodemscoreeICLRRuntimeHost

 CorBindToRuntimeEx 

ICLRControlIHostControl

 Assembly 

Initialization Flow:Host :mscoree :Runtime

CorBindToRuntimeEx

ICLRRuntimeHost

SetHostControl

StartInitialization

ICLRControlStatus

GetCLRControl

ICLRControl

ExecuteInDefaultAppDomain

Assembly Loading

ICLRAssemblyReferenceListICLRAssemblyIdentityManager

• The location from which assemblies are loaded

• The way versions are managed

• The formats from which assemblies can be loaded

Customize

IHostAssemblyManagerIHostAssemblyStore

Synchronization Management

IHostSyncManager ICLRSyncManager

Enables the host to implement its own synchronization primitives for the runtime to use.

Custom

Events IHostManualEvent, IHostAutoEvent

Critical Section

Semaphore IHostSemaphore

IHostCrst

Policy Management

ICLRPolicyManager IHostPolicyManager

Enables the host to specify the way program failures are handled, to support different reliability requirements.

NoActionThrowExceptionAbortThread RudeAbortThread UnloadAppDomain RudeUnloadAppDomain ExitProcess FastExitProcess RudeExitProcess DisableRuntime

NonCriticalResourceCriticalResourceFatalRuntimeOrphanedLockStackOverflow

ThreadAbortThreadRudeAbortInNonCriticalRegionThreadRudeAbortInCriticalRegionAppDomainUnloadAppDomainRudeUnloadProcessExitFinalizerRun

ActionsFailures

Events

Host ProtectionEnables the host to enforce its own programming model, by

preventing the use of specified types or members.

ICLRHostProtectionManager

Reflection

Licensing

Synchronization

UI Components

Thread Pool ManagementEnables the host to implement its own thread pool for the

runtime to use.

IHostThreadPoolManager

GetAvailableThreads GetMaxThreads GetMinThreads QueueUserWorkItem SetMaxThreads SetMinThreads

I/O Completion

IHostIoCompletionManager

Enables the host to implement its own implementation of asynchronous input/output.

ICLRIoCompletionManager 

CLRHost

IHostIoCompletionManager

ICLRIoCompletionManager

IO Operations Calls

Results & Feedback

Profiling• Class loading and unloading

events.

• Thread creation and destruction events.

• Function entry and exit events.

• Exceptions.

• Transitions between different runtime contexts.

• Information about runtime suspensions.

• Information about the runtime memory heap and garbage collection activity.

ApplicationFor

Profiling

CLR

HOST IPC Transport

ProfilerUser

Interface

Profile Target Profiler

ICorProfilerInfo

ICorProfilerCallback

Debugging

ApplicationFor

Debugging

CLR

HOST IPC Transport

DebuggerUser

Interface

Profile Target Debugger

ICorDebug

ICorDebugManagedCallback

• Accessing Call Stacks and Variables

• Accessing IL Code and Native Code

• On-the-Fly Data and Code modifications

• Runtime Expressions Evaluation

• IL Code Injections

• Custom Breakpoints

• Step by Step Execution

Practical Case

ArchitectureDomestic Area

New ArchitecturePrinter

Domestic Area

Internet

Windows User Mode Driver Framework

Virtual Printer Driver

CLR Host

.NET Data Converter

.NET Data Converter

.NET Data Converter

Native

Native

Native

CLR Hosting vs COM Integration

Simple Programming Model

Fully Managed

Good Performance

Flexible Programming Model

High Reliability

Tailored Integration with Native Services

Native Programming Environment

Low Reliability

COM Infrastructure Availability

Complex Diagnostics

Strange Errors

THANK YOU