Compartir a través de


IMetaDataDispenser::OpenScope Method

Opens an existing, on-disk file and maps its metadata into memory.

HRESULT OpenScope (
    [in]  LPCWSTR     szScope, 
    [in]  DWORD       dwOpenFlags, 
    [in]  REFIID      riid, 
        [out] IUnknown    **ppIUnk
);

Parameters

  • szScope
    [in] The name of the file to be opened. The file must contain common language runtime (CLR) metadata.

  • dwOpenFlags
    [in] A value of the CorOpenFlags enumeration to specify the mode (read, write, and so on) for opening.

  • riid
    [in] The IID of the desired metadata interface to be returned; the caller will use the interface to import (read) or emit (write) metadata.

    The value of riid must specify one of the "import" or "emit" interfaces. Valid values are IID_IMetaDataEmit, IID_IMetaDataImport, IID_IMetaDataAssemblyEmit, IID_IMetaDataAssemblyImport, IID_IMetaDataEmit2, or IID_IMetaDataImport2.

  • ppIUnk
    [out] The pointer to the returned interface.

Remarks

The in-memory copy of the metadata can be queried using methods from one of the "import" interfaces, or added to using methods from the one of the "emit" interfaces.

If the target file does not contain CLR metadata, the OpenScope method will fail.

In the .NET Framework version 1.0 and version 1.1, if a scope is opened with dwOpenFlags set to ofRead, it is eligible for sharing. That is, if subsequent calls to OpenScope pass in the name of a file that was previously opened, the existing scope is reused and a new set of data structures is not created. However, problems can arise due to this sharing.

In the .NET Framework version 2.0, scopes opened with dwOpenFlags set to ofRead are no longer shared. Use the ofReadOnly value to allow the scope to be shared. When a scope is shared, queries that use "read/write" metadata interfaces will fail.

Requirements

Platform: Windows 2000, Windows XP, Windows Server 2003 family

Header: Cor.h

Library: Used as a resource in MsCorEE.dll

.NET Framework Version: 2.0, 1.1, 1.0

See Also

Concepts

IMetaDataDispenser Interface

IMetaDataDispenserEx Interface

IMetaDataAssemblyEmit Interface

IMetaDataAssemblyImport Interface

IMetaDataEmit Interface

IMetaDataEmit2 Interface

IMetaDataImport Interface

IMetaDataImport2 Interface