what is application domain?

Answer Posted / bsatish

AppDomains are usually created by hosts. Examples of hosts
are the Windows Shell, ASP.NET and IE. When you run a .NET
application from the command-line, the host is the Shell.
The Shell creates a new AppDomain for every application.
AppDomains can also be explicitly created by .NET
applications. Here is a C# sample which creates an
AppDomain, creates an instance of an object inside it, and
then executes one of the object's methods. Note that you
must name the executable 'appdomaintest.exe' for this code
to work as-is.
• using System;
• using System.Runtime.Remoting;

• public class CAppDomainInfo : MarshalByRefObject
• {
• public string GetAppDomainInfo()
• {
• return "AppDomain = " +
AppDomain.CurrentDomain.FriendlyName;
• }
• }
• public class App
• {
• public static int Main()
• {
• AppDomain ad =
AppDomain.CreateDomain( "Andy's new domain", null, null );
• ObjectHandle oh = ad.CreateInstance
( "appdomaintest", "CAppDomainInfo" );
• CAppDomainInfo adInfo =
(CAppDomainInfo)(oh.Unwrap());
• string info =
adInfo.GetAppDomainInfo();
• Console.WriteLine( "AppDomain
info: " + info );
• return 0;
• }
}

Is This Answer Correct ?    3 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain the term inheritance in C#.

611


What is object pool in .net?

609


How Do You Convert A Value-type To A Reference-type?

605


Is var a data type?

605


Why does my windows application pop up a console window every time I run it?

607






What are access modifiers in c#?

625


Explain the difference between the debug class and trace class?

571


Can you instantiate an abstract class c#?

577


What is a dimensional array?

538


Can you store strings in arrays?

637


What is difference between a constant and read-only in C#?

614


How does c# generics and c++ templates compare?

558


What is the difference between internal and private in c#?

586


Why do we need generics in c#?

588


What is reflection in c#?

578