AppDomain.ActivationContext is NULL

一曲冷凌霜 提交于 2019-12-25 02:24:37

问题


I have created an AppDomain in my application. Below is the code I have used

AppDomainSetup domaininfo = new AppDomainSetup();
domaininfo.ApplicationBase = "C:\\";
AppDomain domain = AppDomain.CreateDomain("MyDomain", null, domaininfo);
ActivationContext context = domain.ActivationContext;

But the ActivationContext is null in above snippet. Can anyone help me on this. Thanks in Advance.


回答1:


It's null by default if you don't specify an ActivationContext.

If you want an ActivationContext, use the AppDomainSetup constructor that takes an ActivationContext parameter.

Or the constructor that takes ActivationArguments which in turn has an ActivationContext.




回答2:


ActivationContext is byte array that contains the ClickOnce deployment manifest for the application that is associated with this ActivationContext. It is used to get the ClickOnce deployment manifest for the current application.

if a ClickOnce application is running in the current AppDomain by checking the AppDomain.CurrentDomain.ActivationContext property. If that value is non-null, then the domain is running a ClickOnce application.

This can be examined by Checking the "Enable ClickOnce security settings" in Project Properties "Security" tab

In the correct context ClickOnce security settings is disabled. Because it is not a click once deployment. So the context also will be null by default



来源:https://stackoverflow.com/questions/21044501/appdomain-activationcontext-is-null

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!