Reference 인터페이스
프로젝트에서 하나의 참조를 나타냅니다. 프로젝트에 참조를 포함시키면 이 참조에 포함된 모든 공용 멤버를 사용할 수 있습니다. 프로젝트에 다른 .NET 프로젝트, .NET 어셈블리 및 COM 개체에 대한 참조가 포함될 수 있습니다.
네임스페이스: VSLangProj
어셈블리: VSLangProj(vslangproj.dll)
구문
‘선언
<GuidAttribute("35D6FB50-35B6-4C81-B91C-3930B0D95386")> _
Public Interface Reference
‘사용 방법
Dim instance As Reference
[GuidAttribute("35D6FB50-35B6-4C81-B91C-3930B0D95386")]
public interface Reference
[GuidAttribute(L"35D6FB50-35B6-4C81-B91C-3930B0D95386")]
public interface class Reference
/** @attribute GuidAttribute("35D6FB50-35B6-4C81-B91C-3930B0D95386") */
public interface Reference
GuidAttribute("35D6FB50-35B6-4C81-B91C-3930B0D95386")
public interface Reference
설명
Reference 개체는 VSProject 개체의 References 컬렉션에 포함됩니다. Reference 개체에는 어셈블리(Visual Studio 프로젝트 포함) 개체와 COM 개체라는 두 가지 형식이 있습니다. 다른 프로젝트에 참조가 있는 경우 프로젝트간 참조라고 하며 어셈블리 참조로 간주됩니다.
예제
다음 예제에서는 템플릿에서 새 프로젝트를 만들고 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