. Net (C #): obtains information about clickonce applications through activationcontext.

Source: Internet
Author: User

For clickonce applicationsProgramYou can use activationcontext to activate the context. This class provides access to the Application List (application manifest. Appdomain. activationcontext can be used to obtain the activation context of the current application domain. Activationcontext currently has four attributes. Application (or deploy) manifestbytes can obtain the clickonce application (or deployment) List array. The form attribute (corresponding to an enumeration value) indicates whether it is in the clickonce storage area.

 

ArticleThe main content is the identity attribute in the four attributes of activationcontext to obtain an application identity: applicationidentity class (in the system namespace ).

The fullname attribute of the applicationidentity class contains almost all program information of the clickonce application (including codebase), and The applicationidentity. codebase attribute is the URL of the program deployment list.

Note:

 

If you want to run the followingCodeMake sure that the application is deployed with clickonce.

For console programs, it is best to add the console. readkey method at the end of the program, otherwise the output will not be visible.

Console.Readkey (True);

 

Code:

VaRAppidenity= Appdomain.Currentdomain.Activationcontext.Identity;

Console.Writeline (appidenity.Fullname );

Console.Writeline (appidenity.Codebase );

 

Output (note that fullname contains a lot of information ):

 

For more detailed information, you can construct an applicationsecurityinfo type (through the activationcontext type). applicationid of applicationsecurityinfo returns an applicationid object. Applicationid contains many information, such as name, version, cultural information, and public key tag.

 

Code (note that applicationsecurityinfo is in the system. Security. Policy namespace, while applicationid is in the system namespace ):

// + Using system. Security. Policy;

VaRAppsecurinf= New Applicationsecurityinfo(Appdomain.Currentdomain.Activationcontext );

VaRAppid=Appsecurinf.Applicationid;

 

Console.Writeline (appid.Name );

Console.Writeline (appid.Version );

Console.Writeline (appid.Processorarchitecture );

Console.Writeline (Bitconverter.Tostring (appid.Publickeytoken ));

 

Console.Writeline ("List evidence");

VaRITER=Appsecurinf.Applicationevidence.Gethostenumerator ();

While(ITER.Movenext ())

Console.Writeline (ITER.Current.Tostring ());

 

Output:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.