ApplicationId Class
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Contains information used to uniquely identify a manifest-based application. This class cannot be inherited.
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
- Inheritance
-
ApplicationId
- Attributes
The following code example displays the ApplicationId properties by obtaining the ApplicationId from an ApplicationSecurityInfo instance created using the ActivationContext for the currently executing manifest-based application.
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
An application identity consists of the publisher's public key, the application name, the target processor architecture, the application culture, and the application version. The application identity properties values correspond to information contained in the application manifest. For more information about the application manifest, see ClickOnce Application Manifest.
ApplicationId is used by the ApplicationSecurityInfo class to identify a manifest-based application.
Application |
Initializes a new instance of the ApplicationId class. |
Culture |
Gets a string representing the culture information for the application. |
Name |
Gets the name of the application. |
Processor |
Gets the target processor architecture for the application. |
Public |
Gets the public key token for the application. |
Version |
Gets the version of the application. |
Copy() |
Creates and returns an identical copy of the current application identity. |
Equals(Object) |
Determines whether the specified ApplicationId object is equivalent to the current ApplicationId. |
Get |
Gets the hash code for the current application identity. |
Get |
Gets the Type of the current instance. (Inherited from Object) |
Memberwise |
Creates a shallow copy of the current Object. (Inherited from Object) |
To |
Creates and returns a string representation of the application identity. |
Produkt | Versionen |
---|---|
.NET | Core 2.0, Core 2.1, Core 2.2, Core 3.0, Core 3.1, 5, 6, 7, 8, 9 |
.NET Framework | 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1 |
.NET Standard | 2.0, 2.1 |
Feedback zu .NET
.NET ist ein Open Source-Projekt. Wählen Sie einen Link aus, um Feedback zu geben: