次の方法で共有


Reference3.StrongName プロパティ

参照が公開キーと秘密キーのペアで署名されているかどうかを示す値を取得します。

名前空間:  VSLangProj80
アセンブリ:  VSLangProj80 (VSLangProj80.dll 内)

構文

'宣言
ReadOnly Property StrongName As Boolean
bool StrongName { get; }
property bool StrongName {
    bool get ();
}
abstract StrongName : bool
function get StrongName () : boolean

プロパティ値

型 : System.Boolean
参照が公開キーと秘密キーのペアで署名されているかどうかを示す boolean 値。

解説

返される値は参照の種類によって変わります。

参照型

返される値

Assembly

参照が厳密な名前を持つ場合は、True になります。

COM

常に False になります。COM オブジェクトは厳密な名前を持ちません。

グローバル アセンブリ キャッシュに格納できるのは、厳密な名前を持つアセンブリだけです。厳密な名前およびグローバル アセンブリ キャッシュの詳細については、「厳密な名前付きアセンブリ」、「グローバル アセンブリ キャッシュ」、および「アセンブリとグローバル アセンブリ キャッシュの使用」を参照してください。

この例では、開いた Visual Basic または Visual C# プロジェクトにアセンブリと COM 参照を追加します。次に、アセンブリの参照に厳密な名前があるかどうかを確認します。COM 参照の場合、StrongName は false です。このサンプル コードをアドインとして実行するには、「方法 : オートメーション オブジェクト モデルのコード例をコンパイルおよび実行する」を参照してください。

追加する参照の既定のパスは、adodb.dll の場合は <installation root>\Program Files\Microsoft.NET\Primary Interop Assemblies で、spcommon.dll の場合は <installation root>\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 インターフェイス

StrongName オーバーロード

VSLangProj80 名前空間