Partilhar via


IMetaDataAssemblyImport::FindAssembliesByName Method

Gets an array of assemblies with the specified szAssemblyName parameter, using the standard rules employed by the common language runtime (CLR) for resolving references.

HRESULT FindAssembliesByName (
    [in]  LPCWSTR     szAppBase, 
    [in]  LPCWSTR     szPrivateBin, 
    [in]  LPCWSTR     szAssemblyName, 
    [out] IUnknown    *ppIUnk[], 
    [in]  ULONG       cMax, 
    [out] ULONG       *pcAssemblies
);

Parameters

Parameter Description

szAppBase

[in] The root directory in which to search for the given assembly. If this value is set to null, FindAssembliesByName will look only in the global assembly cache for the assembly.

szPrivateBin

[in] A list of semicolon-delimited subdirectories (for example, "bin;bin2"), under the root directory, in which to search for the assembly. These directories are probed in addition to those specified in the default probing rules.

szAssemblyName

[in] The name of the assembly to find. The format of this string is defined in the class reference page for AssemblyName.

ppIUnk

[in] An array of type IUnknown in which to put the IMetadataAssemblyImport interface pointers.

cMax

[out] The maximum number of interface pointers that can be placed in ppIUnk.

pcAssemblies

[out] The number of interface pointers returned. That is, the number of interface pointers actually placed in ppIUnk.

Return Value

HRESULT Description

S_OK

FindAssembliesByName returned successfully.

S_FALSE

There are no assemblies.

Remarks

Given an assembly name, the FindAssembliesByName method finds the assembly by following the standard rules for resolving assembly references. (For more information, see How the Runtime Locates Assemblies.) FindAssembliesByName allows the caller to configure various aspects of the assembly resolver context, such as application base and private search path.

The FindAssembliesByName method requires the CLR to be initialized in the process in order to invoke the assembly resolution logic. Therefore, you must call CoInitializeEE Function (passing COINITEE_DEFAULT) before calling FindAssembliesByName, and then follow with a call to CoUninitializeCor Function.

FindAssembliesByName returns an IMetaDataImport Interface pointer to the file containing the assembly manifest for the assembly name that is passed in. If the given assembly name is not fully specified (for example, if it does not include a version), multiple assemblies might be returned.

FindAssembliesByName is commonly used by a compiler that attempts to find a referenced assembly at compile time.

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

Reference

IMetaDataAssemblyImport Interface

Concepts

How the Runtime Locates Assemblies