다음을 통해 공유


Reference3.StrongName 속성

참조를 공개/개인 키 쌍으로 서명할지 여부를 가져옵니다.

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

구문

‘선언
ReadOnly Property StrongName As Boolean
bool StrongName { get; }
property bool StrongName {
    bool get ();
}
abstract StrongName : bool with get
function get StrongName () : boolean

속성 값

형식: Boolean
참조를 공개/개인 키 쌍으로 서명할지 여부를 나타내는 boolean 값입니다.

설명

반환 값은 참조 형식에 따라 다릅니다.

참조 형식

반환 값

어셈블리

참조에 강력한 이름이 있으면 true를 반환합니다.

COM

false를 반환합니다. COM 개체에는 강력한 이름이 없습니다.

강력한 이름이 있는 어셈블리만 전역 어셈블리 캐시에 배치될 수 있습니다. 강력한 이름 및 전역 어셈블리 캐시에 대한 자세한 내용은 강력한 이름의 어셈블리, 전역 어셈블리 캐시어셈블리 및 전역 어셈블리 캐시 사용을 참조하십시오.

예제

이 예제에서는 열린 Visual Basic 또는 Visual C# 프로젝트에 어셈블리 및 COM 참조를 추가합니다. 그런 다음 어셈블리 참조의 이름이 강력한 이름인지 여부를 확인합니다. COM 참조의 경우 StrongName은 false입니다. 이 예제를 추가 기능으로 실행하려면 방법: 자동화 개체 모델 코드의 예제 컴파일 및 실행을 참조하십시오.

추가되는 참조의 기본 경로는 adodb.dll의 경우 <설치 루트>\Program Files\Microsoft.NET\Primary Interop Assemblies이고 spcommon.dll의 경우 <설치 루트>\Program Files\Common Files\SpeechEngines\Microsoft입니다. 예제의 <file path>를 이 경로 또는 적절한 다른 파일 경로로 바꿉니다.

Imports VSLangProj
Imports VSLangProj2
Imports VSLangProj80
Public Sub OnConnection(ByVal application As Object, _
 ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, _
 ByRef custom As Array) Implements IDTExtensibility2.OnConnection
    applicationObject = CType(application, DTE2)
    addInInstance = CType(addInInst, AddIn)
    DisplayStrongNameValue(applicationObject)
End Sub
Sub DisplayStrongNameValue(ByVal dte As DTE2)
    Dim aProject As Project
    Dim aVSProject As VSProject2
    aProject = applicationObject.Solution.Projects.Item(1)
    aVSProject = _
    CType(applicationObject.Solution.Projects.Item(1).Object, _
    VSProject2)
    ' Add an Assembly reference and display its strong name value.
    Dim newRef As Reference3
    ' Replace the <file path> with an actual file path.
    newRef = CType(aVSProject.References.Add("<file path>\adodb.dll"), _
    Reference3)
    MsgBox("Added an assembly reference, named: " & newRef.Name)
    MsgBox("The StrongName value of " & newRef.Name & " is " _
    & newRef.StrongName.ToString())
    ' Add a COM reference and display its strong name value.
    ' Replace <file path> with an actual file path.
    newRef = CType(aVSProject.References.Add
("<file path>\spcommon.dll"), Reference3)
    MsgBox("Added a COM reference, named: " & newRef.Name)
    MsgBox("The StrongName value of " & newRef.Name & " is " _
    & newRef.StrongName.ToString())
End Sub
using System.Windows.Forms;
using VSLangProj;
using VSLangProj2;
using VSLangProj80;
public void OnConnection(object application,
 ext_ConnectMode connectMode, object addInInst, ref Array custom)
{
    applicationObject = (DTE2)application;
    addInInstance = (AddIn)addInInst;
    DisplayStrongNameValue(((DTE2)applicationObject));
}
public void DisplayStrongNameValue(DTE2 dte)
{
    // The first project is a Visual Basic or C# project.
VSProject2 vsProject =
((VSProject2)(applicationObject.Solution.Projects.Item(1).Object));
    Reference3 aRef = null;
    // Add an Assembly reference and display its strong name value.
    ' Replace the <file path> with an actual file path.
    aRef = (Reference3)vsProject.References.Add(@"<file path>\adodb.dll");
    MessageBox.Show("Added an Assembly reference, named: "
+ aRef.Name);
MessageBox.Show("The StrongName value of " + aRef.Name + " is "
+ aRef.StrongName.ToString());
    // Add a COM reference and display its strong name value.
    ' Replace <file path> with an actual file path.
aRef = (Reference3)vsProject.References.Add
(@"<file path>\spcommon.dll");
    MessageBox.Show("Added a COM reference named: " + aRef.Name);
    MessageBox.Show("The StrongName value of " + aRef.Name + " is "
+ aRef.StrongName.ToString());
}

.NET Framework 보안

참고 항목

참조

Reference3 인터페이스

VSLangProj80 네임스페이스