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
What is thread life cycle in c#?
What is the difference between finalize() and dispose()?
How many bytes is an int?
What do you mean by object pooling?
What is cookies c#?
How do I use the 'using' keyword with multiple objects?
What is the meaning of 0 in c#?
What is concatenation and when should it be used?
When Should You Call The Garbage Collector In .net?
How do you specify a custom attribute for the entire assembly (rather than for a class)?
List out the differences between array and arraylist in c#?
What is written in c#?
What is append in c#?
How do I format a string in c#?
Is friend a constructor?