20
.NET CLR Hosting API Evgen Napryaglo Intetics

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

  • Upload
    fwdays

  • View
    131

  • Download
    2

Embed Size (px)

Citation preview

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

.NET CLR Hosting APIEvgen NapryagloIntetics

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

1. Runtime Customizations

Runtime

AssemblyLoading

PolicyManagement

HostProtection

MemoryManagement

GarbageCollection

I/O Completion

CLREvents

TaskManagement

SynchronizationManagement

Thread PoolManagement

Application Host – Native Environment

.NET Application Environment

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

Objectives• Monitoring• Diagnostics

• Customization• Restriction

• Integration• Extensibility

Development Operations

Product Development

Enterprise Integration

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

2. Execution & State Monitoring

ProfilingAPI

DebuggingAPI

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

CLR Hosting

Host

Runtime

.NET CodemscoreeICLRRuntimeHost

 CorBindToRuntimeEx 

ICLRControlIHostControl

 Assembly 

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

Initialization Flow:Host :mscoree :Runtime

CorBindToRuntimeEx

ICLRRuntimeHost

SetHostControl

StartInitialization

ICLRControlStatus

GetCLRControl

ICLRControl

ExecuteInDefaultAppDomain

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

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

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

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

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

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

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

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

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

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

runtime to use.

IHostThreadPoolManager

GetAvailableThreads GetMaxThreads GetMinThreads QueueUserWorkItem SetMaxThreads SetMinThreads

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

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

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

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

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

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

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

Practical Case

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

ArchitectureDomestic Area

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

New ArchitecturePrinter

Domestic Area

Internet

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

Windows User Mode Driver Framework

Virtual Printer Driver

CLR Host

.NET Data Converter

.NET Data Converter

.NET Data Converter

Native

Native

Native

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

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

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

THANK YOU