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
属性

示例

下面的代码示例ApplicationId显示属性,方法是从ApplicationSecurityInfo使用 ActivationContext 为当前正在执行的基于清单的应用程序创建的 实例中获取 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()

创建并返回应用程序标识的字符串表示。

适用于