ICorDebugModule2::ApplyChanges Method

Applies the changes in the metadata and the changes in the Microsoft intermediate language (MSIL) code to the running process.

Syntax

HRESULT ApplyChanges (  
    [in] ULONG                       cbMetadata,  
    [in, size_is(cbMetadata)] BYTE   pbMetadata[],  
    [in] ULONG                       cbIL,  
    [in, size_is(cbIL)] BYTE         pbIL[]  
);  

Parameters

cbMetadata
[in] Size, in bytes, of the delta metadata.

pbMetadata
[in] Buffer that contains the delta metadata. The address of the buffer is returned from the IMetaDataEmit2::SaveDeltaToMemory method.

The relative virtual addresses (RVAs) in the metadata should be relative to the start of the MSIL code.

cbIL
[in] Size, in bytes, of the delta MSIL code.

pbIL
[in] Buffer that contains the updated MSIL code.

Remarks

The pbMetadata parameter is in a special delta metadata format (as output by IMetaDataEmit2::SaveDeltaToMemory). pbMetadata takes previous metadata as a base and describes individual changes to apply to that base.

In contrast, the pbIL[] parameter contains the new MSIL for the updated method, and is meant to completely replace the previous MSIL for that method

When the delta MSIL and the metadata have been created in the debugger’s memory, the debugger calls ApplyChanges to send the changes into the common language runtime (CLR). The runtime updates its metadata tables, places the new MSIL into the process, and sets up a just-in-time (JIT) compilation of the new MSIL. When the changes have been applied, the debugger should call IMetaDataEmit2::ResetENCLog to prepare for the next editing session. The debugger may then continue the process.

Whenever the debugger calls ApplyChanges on a module that has delta metadata, it should also call IMetaDataEmit::ApplyEditAndContinue with the same delta metadata on all of its copies of that module’s metadata except for the copy used to emit the changes. If a copy of the metadata somehow becomes out-of-sync with the actual metadata, the debugger can always throw away that copy and obtain a new copy.

If the ApplyChanges method fails, the debug session is in an invalid state and must be restarted.

Requirements

Platforms: See System Requirements.

Header: CorDebug.idl, CorDebug.h

Library: CorGuids.lib

.NET Framework Versions: Available since 2.0