ICLRMetaHost::GetVersionFromFile Method

Updated: March 2011

Gets an assembly's original .NET Framework compilation version (stored in the metadata), given its file path. This method supersedes the GetFileVersion function.

HRESULT GetVersionFromFile (
    [in] LPCWSTR pwzFilePath,
    [out, size_is(*pcchBuffer)] LPWSTR pwzBuffer,
    [in, out] DWORD *pcchBuffer);
);

Parameters

  • pwzFilePath
    [in] The complete assembly file path.

  • pwzbuffer
    [out] The .NET Framework compilation version stored in the metadata, in the format "vA.B[.X]". A, B, and X are decimal numbers that correspond to the major version, the minor version, and the build number. The length of this string is limited to MAX_PATH.

    Note

    This output matches the directory name for the .NET Framework version, as it appears under C:\Windows\Microsoft.NET\Framework.

    Example values are "v1.0.3705", "v1.1.4322", "v2.0.50727", and "v4.0.X", where X depends on the build number installed. Note that the "v" prefix is required.

  • pcchBuffer
    [in, out] The size of pwzbuffer to avoid buffer overruns.

Return Value

This method returns the following specific HRESULTs as well as HRESULT errors that indicate method failure.

HRESULT

Description

S_OK

The method completed successfully.

E_POINTER

pwzbuffer or pcchBuffer is null.

HRESULT_FROM_WIN32(ERROR_INSUFFICIENT_BUFFER)

The buffer is too small.

Requirements

Platforms: See .NET Framework System Requirements.

Header: MetaHost.h

Library: Included as a resource in MSCorEE.dll

.NET Framework Versions: 4

See Also

Reference

ICLRMetaHost Interface

Other Resources

Hosting (Unmanaged API Reference)

Change History

Date

History

Reason

March 2011

Clarified that pwzBuffer must not be null.

Content bug fix.