Share via


Reference2 인터페이스

업데이트: 2007년 11월

VSLangProj 네임스페이스의 Reference 인터페이스를 확장합니다.

네임스페이스:  VSLangProj2
어셈블리:  VSLangProj2(VSLangProj2.dll)

구문

<GuidAttribute("4FFF24C5-5644-4A47-A48A-B74C3F1F8FC8")> _
Public Interface Reference2 _
    Implements Reference

Dim instance As Reference2
[GuidAttribute("4FFF24C5-5644-4A47-A48A-B74C3F1F8FC8")]
public interface Reference2 : Reference
[GuidAttribute(L"4FFF24C5-5644-4A47-A48A-B74C3F1F8FC8")]
public interface class Reference2 : Reference
public interface Reference2 extends Reference

설명

VSProject 개체의 References 컬렉션에서 반환된 Reference 개체는 Reference 인터페이스와 Reference2 인터페이스를 모두 지원합니다. Reference2 멤버에 액세스하려면 이 개체를 Reference2로 캐스팅해야 합니다.

Reference2는 VSLangProj 네임스페이스에 있는 모든 Reference 멤버와 다음 요소를 정의합니다.

예제

다음 예제에서는 템플릿에서 새 프로젝트를 만들고 2개의 참조를 추가한 다음 참조 형식을 표시합니다.

'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

다음 예제에서는 참조 속성에 대한 간단한 보고서를 작성합니다.

' 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

참고 항목

참조

Reference2 멤버

VSLangProj2 네임스페이스