What is an application domain?

Saturday, June 27, 2009

The following is the definition given by Microsoft.

An application domain (often AppDomain) is a virtual process that serves to isolate an application. All objects created within the same application scope (in other words, anywhere along the sequence of object activations beginning with the application entry point) are created within the same application domain. Multiple application domains can exist in a single operating system process, making them a lightweight means of application isolation.

An OS process provides isolation by having a distinct memory address space. While this is effective, it is also expensive, and does not scale to the numbers required for large web servers. The Common Language Runtime, on the other hand, enforces application isolation by managing the memory use of code running within the application domain. This ensures that it does not access memory outside the boundaries of the domain. It is important to note that only type-safe code can be managed in this way (the runtime cannot guarantee isolation when unsafe code is loaded in an application domain).

What is the difference between CCW and RCW ?













Sno

CCW

RCW

1

COM to .NET communication happens through COM Callable Wrapper

.NET to COM Communication happens through Remote Callable Wrappter

How to invoke a method at runtime using Reflection in c#?



You need to call “InvokeMember” method of Reflection to do this.

Let us see this in detail with an example,

1. Create a Class library program and paste the code below,

Reflection Source Program
=========================

using System;
using System.Collections.Generic;
using System.Text;

namespace Employee
{
public class EmployeeDetails
{
private int empid=1;
private string empname="Ram";
private float salary=100000;

public string displayEmployeeDetails()
{
return "Empoyee Id:" + empid + "
" + "Empoyee Name:" + empname + "
" + "Empoyee salary:" + salary + "
";
}
}
}

2. compile it.

3. then create a windows application project and paste the following code

Reflection Program to invoke the method
==================================================
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using Employee;

namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}



private void button1_Click(object sender, EventArgs e)
{
Assembly assembly = Assembly.LoadFrom("E:\\WebExperiments\\Employee\\Employee\\bin\\Debug\\Employee.dll");
foreach (Type type in assembly.GetTypes())
{
// Pick up a class
if (type.IsClass == true)
{
Console.WriteLine("...Found Class : {0}", type.FullName);

}


object ibaseObject = Activator.CreateInstance(type);

object result = null;

result = type.InvokeMember("displayEmployeeDetails",
BindingFlags.Default | BindingFlags.InvokeMethod,
null,
ibaseObject, null);
MessageBox.Show(result.ToString() );
}
}
}
}

4. add reference to the Employee dll

5. run the program and see the method invoked.

Cystal Report Links





www.codeproject.com/KB/cs/CreatingCrystalReports.aspx



http://www.c-sharpcorner.com/Articles/ArticleListing.aspx?SectionID=1&SubSectionID=61



http://www.programmersheaven.com/download/44243/download.aspx



http://www.crystalreportsbook.com/Crystal_Reports_Net_Ch14_4.asp

LinkWithin

Blog Widget by LinkWithin

Recommended Books