Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
CLRCreateInstance Function
Collapse the table of content
Expand the table of content

CLRCreateInstance Function

.NET Framework 4.6 and 4.5

Provides one of three interfaces: ICLRMetaHost, ICLRMetaHostPolicy, or ICLRDebugging.

HRESULT CLRCreateInstance(
    [in]  REFCLSID  clsid,
    [in]  REFIID     riid,
    [out] LPVOID  * ppInterface
);

clsid

[in] One of three class identifiers: CLSID_CLRMetaHost, CLSID_CLRMetaHostPolicy, or CLSID_CLRDebugging.

riid

[in] One of three interface identifiers (IIDs): IID_ICLRMetaHost, IID_ICLRMetaHostPolicy, or IID_ICLRDebugging.

ppInterface

[out] One of three interfaces: ICLRMetaHost, ICLRMetaHostPolicy, or ICLRDebugging.

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

ppInterface is null.

The following table shows the supported combinations for clsid and riid.

rclsid

riid

CLSID_CLRMetaHost

IID_ICLRMetaHost

CLSID_CLRMetaHostPolicy

IID_ICLRMetaHostPolicy

CLSID_CLRDebugging

IID_ICLRDebugging

The following code shows how to use CLRCreateInstance to get all three interfaces:

#include <metahost.h>
#pragma comment(lib, "mscoree.lib")

ICLRMetaHost       *pMetaHost       = NULL;
ICLRMetaHostPolicy *pMetaHostPolicy = NULL;
ICLRDebugging      *pCLRDebugging   = NULL;
HRESULT hr;
hr = CLRCreateInstance(CLSID_CLRMetaHost, IID_ICLRMetaHost,
                    (LPVOID*)&pMetaHost);
hr = CLRCreateInstance (CLSID_CLRMetaHostPolicy, IID_ICLRMetaHostPolicy,
                    (LPVOID*)&pMetaHostPolicy);
hr = CLRCreateInstance (CLSID_CLRDebugging, IID_ICLRDebugging,
                    (LPVOID*)&pCLRDebugging);

Platforms: See .NET Framework System Requirements.

Header: MetaHost.h

Library: Included as a resource in MSCorEE.dll

.NET Framework Versions: 4.6, 4.5.2, 4.5.1, 4.5, 4

Show:
© 2015 Microsoft