방법: 개체 관리자를 사용 하는 라이브러리 등록
기호 검색 도구, 같은 클래스 뷰, 개체 브라우저, 호출 브라우저 및 기호 찾기 결과, 또는 외부 구성 요소를 프로젝트에서 기호를 볼 수 있습니다. 네임 스페이스, 클래스, 인터페이스, 메서드 및 기타 언어 요소 기호를 포함 합니다. 라이브러리가 이러한 기호를 추적 하 고 노출 하는 Visual Studio 도구는 데이터를 채우는 개체 관리자입니다.
개체 관리자는 라이브러리를 모두 사용할 수를 추적 합니다. 각 라이브러리는 개체 관리자에 기호를 기호 검색 도구를 제공 하기 전에 등록 해야 합니다.
일반적으로 VSPackage 로드 될 때 라이브러리를 등록 합니다. 그러나이 나중에 필요에 따라 수행할 수 있습니다. 있는 VSPackage 종료 될 때 라이브러리의 등록.
라이브러리를 등록할 수 있는 RegisterLibrary 메서드. 경우 관리 코드 라이브러리를 사용 하 여 RegisterSimpleLibrary 메서드.
사용 하는 라이브러리의 등록을 취소 하는 UnregisterLibrary 메서드.
개체 관리자에 대 한 참조를 가져오려면 IVsObjectManager2, 전달의 SVsObjectManager ID로 서비스를 GetService 메서드.
등록 및 개체 관리자를 사용 하 여 라이브러리 등록 취소
라이브러리의 개체 관리자에 등록
라이브러리를 만들 수 있습니다.
Private m_CallBrowserLibrary As CallBrowser.Library = Nothing Private m_nLibraryCookie As UInteger = 0 ' Create Library. m_CallBrowserLibrary = New CallBrowser.Library()
private CallBrowser.Library m_CallBrowserLibrary = null; private uint m_nLibraryCookie = 0; // Create Library. m_CallBrowserLibrary = new CallBrowser.Library();
개체에 대 한 참조를 얻을 IVsObjectManager2 를 입력 하 고 호출 하는 RegisterSimpleLibrary 메서드.
Private Sub RegisterLibrary() If m_nLibraryCookie <> 0 Then Throw New Exception("Library already registered with Object Manager") End If ' Obtain a reference to IVsObjectManager2 type object. Dim objManager As IVsObjectManager2 = TryCast(GetService(GetType(SVsObjectManager)), IVsObjectManager2) If objManager Is Nothing Then Throw New NullReferenceException("GetService failed for SVsObjectManager") End If Try Dim hr As Integer = objManager.RegisterSimpleLibrary(m_CallBrowserLibrary, m_nLibraryCookie) Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(hr) Catch e As Exception ' Code to handle any CLS-compliant exception. Trace.WriteLine(e.Message) Throw End Try End Sub
private void RegisterLibrary() { if (m_nLibraryCookie != 0) throw new Exception("Library already registered with Object Manager"); // Obtain a reference to IVsObjectManager2 type object. IVsObjectManager2 objManager = GetService(typeof(SVsObjectManager)) as IVsObjectManager2; if (objManager == null) throw new NullReferenceException("GetService failed for SVsObjectManager"); try { int hr = objManager.RegisterSimpleLibrary(m_CallBrowserLibrary, out m_nLibraryCookie); Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(hr); } catch (Exception e) { // Code to handle any CLS-compliant exception. Trace.WriteLine(e.Message); throw; } }
개체 관리자를 사용 하는 라이브러리의 등록을 취소 하려면
개체에 대 한 참조를 얻을 IVsObjectManager2 를 입력 하 고 호출 하는 UnregisterLibrary 메서드.
Private Sub UnregisterLibrary() If m_nLibraryCookie <> 0 Then ' Obtain a reference to IVsObjectManager2 type object. Dim objManager As IVsObjectManager2 = TryCast(GetService(GetType(SVsObjectManager)), IVsObjectManager2) If objManager Is Nothing Then Throw New NullReferenceException("GetService failed for SVsObjectManager") End If Try objManager.UnregisterLibrary(m_nLibraryCookie) Catch e As Exception ' Code to handle any CLS-compliant exception. Trace.WriteLine(e.Message) Throw Finally m_nLibraryCookie = 0 End Try End If End Sub
private void UnregisterLibrary() { if (m_nLibraryCookie != 0) { // Obtain a reference to IVsObjectManager2 type object. IVsObjectManager2 objManager = GetService(typeof(SVsObjectManager)) as IVsObjectManager2; if (objManager == null) throw new NullReferenceException("GetService failed for SVsObjectManager"); try { objManager.UnregisterLibrary(m_nLibraryCookie); } catch (Exception e) { // Code to handle any CLS-compliant exception. Trace.WriteLine(e.Message); throw; } finally { m_nLibraryCookie = 0; } } }
참고 항목
작업
방법: 개체 관리자에는 라이브러리에서 제공 하는 기호 목록 노출