Partager via


IVsSolution.GetProjectOfProjref Method

Returns a hierarchy for the specified project reference string.

Namespace:  Microsoft.VisualStudio.Shell.Interop
Assembly:  Microsoft.VisualStudio.Shell.Interop (in Microsoft.VisualStudio.Shell.Interop.dll)

Syntax

'Déclaration
Function GetProjectOfProjref ( _
    pszProjref As String, _
    <OutAttribute> ByRef ppHierarchy As IVsHierarchy, _
    <OutAttribute> ByRef pbstrUpdatedProjref As String, _
    <OutAttribute> puprUpdateReason As VSUPDATEPROJREFREASON() _
) As Integer
'Utilisation
Dim instance As IVsSolution
Dim pszProjref As String
Dim ppHierarchy As IVsHierarchy
Dim pbstrUpdatedProjref As String
Dim puprUpdateReason As VSUPDATEPROJREFREASON()
Dim returnValue As Integer

returnValue = instance.GetProjectOfProjref(pszProjref, _
    ppHierarchy, pbstrUpdatedProjref, _
    puprUpdateReason)
int GetProjectOfProjref(
    string pszProjref,
    out IVsHierarchy ppHierarchy,
    out string pbstrUpdatedProjref,
    VSUPDATEPROJREFREASON[] puprUpdateReason
)
int GetProjectOfProjref(
    [InAttribute] String^ pszProjref, 
    [OutAttribute] IVsHierarchy^% ppHierarchy, 
    [OutAttribute] String^% pbstrUpdatedProjref, 
    [OutAttribute] array<VSUPDATEPROJREFREASON>^ puprUpdateReason
)
function GetProjectOfProjref(
    pszProjref : String, 
    ppHierarchy : IVsHierarchy, 
    pbstrUpdatedProjref : String, 
    puprUpdateReason : VSUPDATEPROJREFREASON[]
) : int

Parameters

  • pszProjref
    Type: System.String

    [in] Pointer to the existing project reference string, if applicable. Can be nulla null reference (Nothing in Visual Basic).

  • pbstrUpdatedProjref
    Type: System.String%

    [out] Pointer to the updated project reference string.

Return Value

Type: System.Int32

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

From vsshell.idl:

HRESULT IVsSolution::GetProjectOfProjref(
   [in] LPCOLESTR pszProjref,
   [out] IVsHierarchy **ppHierarchy,
   [out] BSTR *pbstrUpdatedProjref,
   [out] VSUPDATEPROJREFREASON *puprUpdateReason
);

There are two scenarios for this method:

  • The project reference tracks when the project is renamed within one solution. When attempting to bind a project reference, the project GUID is first attempted by calling GetProjectOfGuid. If this call succeeds and the project has been renamed, then the updated project reference is also provided for the client.

  • Projects are added to a new solution, and the project reference is still able to bind. If the GUID fails to bind, then an attempt is made to locate the project by using the type/name information. If this succeeds, then an updated project reference that includes the new project is returned.

The contents of the project reference are opaque to the client. However, in order to support these two scenarios for our internal implementation, we need to have a project reference string that is composed of the following information:

  • Project GUID assigned and maintained by the solution file

  • Project type (or name)

The following is a description of how the GetProjectOfProjref method is used to support drag-and-drop operations:

The CF_VSPROJECTITEMS and CF_VSPROJECTS clipboard formats use the DROPFILES structure in the same manner as CF_HDROP or CF_PRINTERS. The data that follows the DROPFILES structure is a double-NULL-terminated list of Projref strings. The consumer of the drop operation can use the Windows API DragQueryFile to examine the data in the DROPFILES structure. CF_VSPROJECTS format is offered when the Projref strings identify projects as a whole, that is, *pitemid == VSITEMID_ROOT. The CF_VSPROJECTITEMS format is offered when the Projref strings identify one or more individual project items. Either CF_VSPROJECTS or CF_VSPROJECTITEMS should be offered, but never both.

Permissions

See Also

Reference

IVsSolution Interface

IVsSolution Members

Microsoft.VisualStudio.Shell.Interop Namespace