共用方式為


ApplicationId 類別

定義

包含用來唯一識別資訊清單架構應用程式的資訊。 此類別無法獲得繼承。

public ref class ApplicationId sealed
public sealed class ApplicationId
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public sealed class ApplicationId
type ApplicationId = class
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type ApplicationId = class
Public NotInheritable Class ApplicationId
繼承
ApplicationId
屬性

範例

下列程式碼範例會從 ApplicationSecurityInfo 使用 ActivationContext 目前執行之資訊清單型應用程式的 所建立的 實例取得 ApplicationId ,以顯示 ApplicationId 屬性。

using System;
using System.Collections;
using System.Text;
using System.Security.Policy;
using System.Reflection;
using System.Security;

namespace ActivationContextSample
{
    public class Program : MarshalByRefObject
    {
        public static void Main(string[] args)
        {
            Console.WriteLine("Full name = " +
                AppDomain.CurrentDomain.ActivationContext.Identity.FullName);
            Console.WriteLine("Code base = " +
                AppDomain.CurrentDomain.ActivationContext.Identity.CodeBase);
            ApplicationSecurityInfo asi = new ApplicationSecurityInfo(AppDomain.CurrentDomain.ActivationContext);

            Console.WriteLine("ApplicationId.Name property = " + asi.ApplicationId.Name);
            if (asi.ApplicationId.Culture != null)
                Console.WriteLine("ApplicationId.Culture property = " + asi.ApplicationId.Culture.ToString());
            Console.WriteLine("ApplicationId.ProcessorArchitecture property = " + asi.ApplicationId.ProcessorArchitecture);
            Console.WriteLine("ApplicationId.Version property = " + asi.ApplicationId.Version);
            // To display the value of the public key, enumerate the Byte array for the property.
            Console.Write("ApplicationId.PublicKeyToken property = ");
            byte[] pk = asi.ApplicationId.PublicKeyToken;
            for (int i = 0; i < pk.GetLength(0); i++)
                Console.Write("{0:x}", pk[i]);

            Console.Read();
        }

        public void Run()
        {
            Main(new string[] { });
            Console.ReadLine();
        }
    }
}
open System
open System.Collections
open System.Text
open System.Security.Policy
open System.Reflection
open System.Security

let main _ =
    printfn $"Full name = {AppDomain.CurrentDomain.ActivationContext.Identity.FullName}"
    printfn $"Code base = {AppDomain.CurrentDomain.ActivationContext.Identity.CodeBase}"
    let asi = ApplicationSecurityInfo AppDomain.CurrentDomain.ActivationContext

    printfn $"ApplicationId.Name property = {asi.ApplicationId.Name}"
    if asi.ApplicationId.Culture <> null then
        printfn $"ApplicationId.Culture property = {asi.ApplicationId.Culture}"
    printfn $"ApplicationId.ProcessorArchitecture property = {asi.ApplicationId.ProcessorArchitecture}"
    printfn $"ApplicationId.Version property = {asi.ApplicationId.Version}"
    // To display the value of the public key, enumerate the Byte array for the property.
    printf "ApplicationId.PublicKeyToken property = "
    let pk = asi.ApplicationId.PublicKeyToken
    for i = 0 to pk.GetLength 0 - 1 do
        printf $"{pk[i]:x}"
    Console.Read()
Imports System.Collections
Imports System.Text
Imports System.Security.Policy
Imports System.Reflection
Imports System.Security
Imports System.Security.Permissions



Public Class Program
    Inherits MarshalByRefObject
    <SecurityPermission(SecurityAction.Demand, ControlDomainPolicy:=true)> _
    Public Shared Sub Main(ByVal args() As String) 
        Console.WriteLine("Full name = " + _
            AppDomain.CurrentDomain.ActivationContext.Identity.FullName)
        Console.WriteLine("Code base = " + _
            AppDomain.CurrentDomain.ActivationContext.Identity.CodeBase)
        Dim asi As New ApplicationSecurityInfo(AppDomain.CurrentDomain.ActivationContext)     
        Console.WriteLine("ApplicationId.Name property = " + asi.ApplicationId.Name)
        If Not (asi.ApplicationId.Culture Is Nothing) Then
            Console.WriteLine("ApplicationId.Culture property = " + _
            asi.ApplicationId.Culture.ToString())
        End If
        Console.WriteLine("ApplicationId.ProcessorArchitecture property = " + _
            asi.ApplicationId.ProcessorArchitecture)
        Console.WriteLine("ApplicationId.Version property = " + _
            asi.ApplicationId.Version.ToString())
        ' To display the value of the public key, enumerate the Byte array for the property.
        Console.Write("ApplicationId.PublicKeyToken property = ")
        Dim pk As Byte() = asi.ApplicationId.PublicKeyToken
        Dim i As Integer
        For i = 0 To (pk.GetLength(0))
            Console.Write("{0:x}", pk(i))
        Next i 
        Console.Read()
    
    End Sub
    
    Public Sub Run() 
        Main(New String() {})  
    End Sub
End Class

備註

應用程式身分識別是由發行者的公開金鑰、應用程式名稱、目標處理器架構、應用程式文化特性和應用程式版本所組成。 應用程式識別屬性值會對應至應用程式資訊清單中包含的資訊。 如需應用程式資訊清單的詳細資訊,請參閱 ClickOnce 應用程式資訊清單

ApplicationIdApplicationSecurityInfo 類別用來識別以資訊清單為基礎的應用程式。

建構函式

ApplicationId(Byte[], String, Version, String, String)

初始化 ApplicationId 類別的新執行個體。

屬性

Culture

取得字串,表示應用程式的文化特性資訊。

Name

取得應用程式的名稱。

ProcessorArchitecture

取得應用程式的目標處理器架構。

PublicKeyToken

取得應用程式的公開金鑰語彙基元。

Version

取得應用程式的版本。

方法

Copy()

建立並傳回目前應用程式識別的相同複本。

Equals(Object)

判斷指定的 ApplicationId 物件是否相當於目前的 ApplicationId

GetHashCode()

取得目前應用程式識別的雜湊程式碼。

GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

建立並傳回應用程式識別的字串表示。

適用於