Reference2 Interface
Extends the Reference interface of the VSLangProj namespace.
Namespace: VSLangProj2
Assembly: VSLangProj2 (in VSLangProj2.dll)
Syntax
'Declaration
<GuidAttribute("4FFF24C5-5644-4A47-A48A-B74C3F1F8FC8")> _
Public Interface Reference2 _
Inherits Reference
[GuidAttribute("4FFF24C5-5644-4A47-A48A-B74C3F1F8FC8")]
public interface Reference2 : Reference
[GuidAttribute(L"4FFF24C5-5644-4A47-A48A-B74C3F1F8FC8")]
public interface class Reference2 : Reference
[<GuidAttribute("4FFF24C5-5644-4A47-A48A-B74C3F1F8FC8")>]
type Reference2 =
interface
interface Reference
end
public interface Reference2 extends Reference
The Reference2 type exposes the following members.
Properties
Name | Description | |
---|---|---|
BuildNumber | Gets the build number of the reference. Read-only. (Inherited from Reference.) | |
BuildNumber | Gets the build number of the reference. Read-only. | |
Collection | Gets the collection containing the object supporting this property or contained within this code construct. (Inherited from Reference.) | |
Collection | Gets a collection of References. | |
ContainingProject | Gets the project that the selected item is a part of. Read-only. (Inherited from Reference.) | |
ContainingProject | Gets the Project containing the reference. | |
CopyLocal | Determines whether the reference is copied to the local bin path. (Inherited from Reference.) | |
CopyLocal | Determines whether the reference is copied to the local bin path. | |
Culture | Gets the culture string of a reference. Read-only. (Inherited from Reference.) | |
Culture | Gets the culture string of a reference. Read-only. | |
Description | Gets a text description of the reference. Read-only. (Inherited from Reference.) | |
Description | Gets a text description of the reference. Read-only. | |
DTE | Gets the top-level extensibility object. (Inherited from Reference.) | |
DTE | Gets the top-level extensibility object. | |
Extender[String] | Gets the requested Extender object if it is available for this object. (Inherited from Reference.) | |
Extender[String] | Returns the requested Extender object if it is available for this object. | |
ExtenderCATID | Gets the Extender category ID (CATID) for the object. (Inherited from Reference.) | |
ExtenderCATID | Gets the Extender category ID (CATID) for the object. | |
ExtenderNames | Gets a list of available Extenders for the object. (Inherited from Reference.) | |
ExtenderNames | Gets a list of available Extenders for the object. | |
Identity | Gets the unique identifier of the reference. Read-only. (Inherited from Reference.) | |
Identity | Gets the unique identifier of the reference. Read-only. | |
MajorVersion | Gets the major version number of the reference. Read-only. (Inherited from Reference.) | |
MajorVersion | Gets the major version number of the reference. Read-only. | |
MinorVersion | Gets the minor version number of the reference. Read-only. (Inherited from Reference.) | |
MinorVersion | Gets the minor version number of the reference. Read-only. | |
Name | Gets the name of the object. Read-only. (Inherited from Reference.) | |
Name | Gets the name of the object. Read-only. | |
Path | Gets the path to the reference file. Read-only. (Inherited from Reference.) | |
Path | Gets the path to the reference file. Read-only. | |
PublicKeyToken | Gets the public key token for the referenced assembly. (Inherited from Reference.) | |
PublicKeyToken | Gets the public key token for the referenced assembly. | |
RevisionNumber | Gets the revision number of the reference. Read-only. (Inherited from Reference.) | |
RevisionNumber | Gets the revision number of the reference. Read-only. | |
RuntimeVersion | Gets and sets the version of the runtime the reference was built against. Read-only. | |
SourceProject | Gets a Project object if the reference is a project. Otherwise, it returns Nothing (a nulla null reference (Nothing in Visual Basic) reference). Read-only. (Inherited from Reference.) | |
SourceProject | Gets a Project object if the reference is a project. Otherwise, it returns Nothing (a nulla null reference (Nothing in Visual Basic) reference). Read-only. | |
StrongName | Gets whether the reference is signed with a public/private key pair. Read-only. (Inherited from Reference.) | |
StrongName | Gets whether the reference is signed with a public/private key pair. Read-only. | |
Type | Gets a prjReferenceType value indicating whether the reference is an assembly or a COM component. Read-only. (Inherited from Reference.) | |
Type | Gets a prjReferenceType value indicating whether the reference is an assembly or a COM component. Read-only. | |
Version | Gets the version of the selected reference. (Inherited from Reference.) | |
Version | Gets the version of the selected reference. |
Top
Methods
Name | Description | |
---|---|---|
Remove() | Gets the reference from the References object that contains it. (Inherited from Reference.) | |
Remove() | Removes the reference from the References object that contains it. |
Top
Remarks
Reference objects returned by the References collection of the VSProject object support both the Reference interface and the Reference2 interface. Cast the object to Reference2 to access the Reference2 members.
Reference2 defines all the Reference members found in the VSLangProj namespace, plus:
Examples
The following example creates a new project from a template, adds two references, and displays their types.
'Macro Editor
Imports VSLangProj
Sub NewProject()
Dim newName As String = InputBox("New project name:")
' Create a new project in the solution based on an existing
' project.
Dim newProject As Project = DTE.Solution.AddFromTemplate( _
"C:\TemplatePath\Template.vbproj", _
"C:\ProjectPath\" & newName, newName)
' Add a COM reference and display its type.
Dim vsProject As VSProject = CType(newProject.Object, VSProject)
Dim newRef As Reference
newRef = vsProject.References.Add("C:\WINNT\System32\msmask32.ocx")
MsgBox(GetRefTypeName(newRef))
' Add an Assembly reference and display its type, "Assembly".
newRef = vsProject.References.Add("C:\SomeProject\bin\SomeProject.dll")
MsgBox(GetRefTypeName(newRef))
End Sub
Private Function GetRefTypeName(ByVal ref As Reference) _
As String
Dim type As String
Select Case ref.Type
Case prjReferenceType.prjReferenceTypeActiveX
type = "COM"
Case prjReferenceType.prjReferenceTypeAssembly
type = "Assembly"
End Select
Return type
End Function
The following example creates a short report of a reference's properties.
' Macro Editor
' Create a small report about a reference.
Imports VSLangProj
Function ReportReferences(ByVal aRef As Reference) As String
Dim report As String = ""
Dim type As String
' Each entry in the ArrayList will contain a label and a value.
Dim ht As System.Collections.ArrayList = _
New System.Collections.ArrayList()
With aRef
ht.Add(New String() {"Name", .Name})
ht.Add(New String() {"Description", .Description})
ht.Add(New String() {"Version", String.Format("{0}.{1}.{2}.{3}", _
.MajorVersion, .MinorVersion, .BuildNumber, .RevisionNumber)})
ht.Add(New String() {"Location", .ContainingProject.FullName})
Select Case .Type
Case prjReferenceType.prjReferenceTypeActiveX
type = "COM"
Case prjReferenceType.prjReferenceTypeAssembly
type = "Assembly"
End Select
ht.Add(New String() {"Type", type})
ht.Add(New String() {"Culture", .Culture})
End With
Dim datas() As String
For Each datas In ht
report &= datas(0) & ControlChars.Tab & datas(1) & ControlChars.CrLf
Next
Return report
End Function