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: