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
State the top.NET class that everything is derived from?
Why objects are stored in heap in c#?
What is a partial method?
What is the role of the datareader class in ado.net connections?
What does namespace mean?
What are jump statements in c#?
Where is the main method in c#?
Is var a data type?
What are value types in c#?
What is the use of flag in c#?
Where do we set the min and max pool size for connection pooling?
Explain deadlock?
How to put assembly in gac?
What are the different types of assembly?
What is sqldataadapter in c#?