1

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.

Vimal CK
  • 3,543
  • 1
  • 26
  • 47

2 Answers2

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.

Joe
  • 122,218
  • 32
  • 205
  • 338
  • Could you please help me on how to specify ActivationContext in AppDomainSetup() constructor?. I have tried to create an instance of ActivationContext and passed it to the AppDomainSetup constructor. But failed :( – Vimal CK Jan 10 '14 at 12:51
  • What are you trying to achieve? Have you looked at http://msdn.microsoft.com/en-us/library/aa376620(v=vs.85).aspx – Joe Jan 10 '14 at 12:55
  • You are already passing an AppDomainSetup to the AppDomain constructor. You need to pass an ActivationContext to the AppDomainSetup constructor. I'm just rephrasing what I already said in the answer, isn't it clear? – Joe Jan 10 '14 at 13:09
  • Sorry, I wanted to pass an ActivationContext instance into AppDomainSetup constructor not AppDomain constructor. It was a typo. Could you please share some snippet. So that it can be clear and very helpful to me :) – Vimal CK Jan 10 '14 at 13:12
  • The application is not clickonce. so the ActivationContext will be null. – Vimal CK Jan 10 '14 at 13:51
  • So what's the problem? It's normal that it should be null. – Joe Jan 10 '14 at 14:07
1

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

Vimal CK
  • 3,543
  • 1
  • 26
  • 47