References.Add 메서드

프로젝트에 새 참조를 추가합니다.

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

구문

‘선언
‘사용 방법

매개 변수

  • bstrPath
    필수적 요소. COM 또는 .NET Framework 참조의 경로입니다.

    이 매개 변수에는 다음과 같은 3가지 형태가 있습니다.

    • "System"과 같은 단순한 .NET Framework 개체 이름

    • .NET Framework 파일 이름(.tlb, .dll 또는 .ocx 파일)

    • COM 라이브러리 파일(.tlb, .dll, .ocx 또는 .exe 파일). COM 개체의 경우 "D:\SomeApplication\SomeApp.dll"과 같이 경로에 전체 경로와 파일 이름이 포함되어야 합니다. COM.exe 파일 참조를 추가하는 방법은 아래의 "COM 참조" 단원에 나오는 제한 사항을 참조하십시오.

반환 값

Reference 개체를 반환합니다.

설명

bstrPath 매개 변수에 의해 지정된 파일에 형식 라이브러리가 없거나 참조를 확인할 수 없으면 오류가 발생합니다(참조 확인 단원 참조).

Identity, Culture, MajorVersion, MinorVersion, BuildNumberRevisionNumber가 새 참조와 동일한 참조가 프로젝트에 있는 경우 이 메서드는 오류를 생성하지 않습니다. 이것은 bstrPath 매개 변수에 의해 지정된 참조가 프로젝트에 이미 추가되었음을 나타냅니다. 대신 이미 프로젝트에 있는 해당 참조의 ProjectItem이 반환됩니다.

Identity는 같지만 MajorVersion, MinorVersion, BuildNumber, RevisionNumber 또는 Culture가 다른 참조가 프로젝트에 있는 경우 이 메서드는 오류를 생성합니다.

참조를 제거하려면 Remove를 사용합니다.

예제

' Macro Editor
Imports VSLangProj
Sub AddExample()
   ' This example assumes that the first project in the solution is 
   ' either a Visual Basic or C# project.
   Dim aVSProject As VSProject = _
      CType(DTE.Solution.Projects.Item(1).Object, VSProject)
        
   Dim refs As References = aVSProject.References
   ' Adds a reference to a compiled .NET project.
   refs.Add("C:\path\program.dll")
   ' Adds a reference to an installed ActiveX control.
   refs.Add("C:\WINNT\system32\msmask32.ocx")
   ' Adds a reference to System.dll as an example of adding a
   ' reference using just the simple name.
   refs.Add("System")
End Sub

참고 항목

참조

References 인터페이스
References 멤버
VSLangProj 네임스페이스