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
Can abstract classes be final?
What are reflections in c#?
What is an escape sequence? Name some string escape sequences in c#.
How many types of interface are there in c#?
how to insert the data from the grid view to database table though button click.pls send the answer to mail id suri1319@gmail.com
Explain about Destructor method?
Can you explain template pattern?
How many dimensions can an array have?
How do partial classes work in c#?
What is strongly typed view?
What is dbcontext c#?
What are classes in c#?
What are custom exceptions?
What is lazy keyword in c#?
What is activator c#?