Friday 19 August 2011

How to Retrieve a DLL from the GAC


Step 1. Opend Command prompt
Step 2. Browse for GAC/GAC_32/GAC_MSIL Folder
    (C:\Window\assembly\GAC)
    <image>
Step 3. Each assembly have it own folder. So if you need to access the assembly
            Like eg: CrystalDecisions.Enterprise.Franework
    C:\Window\assembly\GAC>cd CrystalDecisions.Enterprise.Franework
step 4. C:\Window\assembly\GAC\CrystalDecisions.Enterprise.Franework>
    Once in the folder, you should see a subfolder for each version of the assembly in the GAC.
    C:\Window\assembly\GAC\CrystalDecisions.Enterprise.Franework>dir
    you can see sub folders in it like This:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\WINDOWS\assembly\GAC\CrystalDecisions.Enterprise.Framework\10.5.3700.0__692fb
ea5521e1304>dir
 Volume in drive C is TECLAB-4
 Volume Serial Number is 3844-D579

 Directory of C:\WINDOWS\assembly\GAC\CrystalDecisions.Enterprise.Framework\10.5
.3700.0__692fbea5521e1304

04/11/2009  02:47 AM    <DIR>          .
04/11/2009  02:47 AM    <DIR>          ..
04/11/2009  02:47 AM            45,056 CrystalDecisions.Enterprise.Framework.dll

04/11/2009  02:47 AM               229 __AssemblyInfo__.ini
               2 File(s)         45,285 bytes
               2 Dir(s)   5,783,031,808 bytes free
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
step 5. Now copy this dll to your prefred location using COPY or XCOPY Command.

 C:\WINDOWS\assembly\GAC\CrystalDecisions.Enterprise.Framework\10.5.3700.0__692fbea5521e1304>xcopy * \jeevandll
 C:CrystalDecisions.Enterprise.Framework.dll
 C:__AssemblyInfo__.ini
 2 File(s) copied

Thursday 11 August 2011

What is Abstraction

Abstraction :

        Abstraction is “the process of identifying common patterns that have systematic variations;
        an abstraction represents the common pattern and provides a means for specifying which variation to use”
(OR)
         Abstraction is the representation of only the essential features of an object

Example Description:(Abstraction and Encapsulation)

#1    Consider an example from the programmer’s view who wants to allow the user to add items to a form/list.
    The user only needs to click a button to add an item (Abstraction).
                The mechanism of how the item is added to the list is not essential for him (Encapsulation)
#2    Example You r driving a car. U does not need to know the internal working of the engine or the way gear changes work,
    to be able to drive the car (Encapsulation). Instead, U needs to know things such as how much turning the steering wheel
    needs, etc... (Abstraction).

Abstract Class in C Sharp

Abstract Class in C Sharp:

    A Class is declared with Abstract keyword, and which is can not be instantiated and they are frequently either partially implemented,
    or not at all implemented..
    It can be used as a Super Class or Base Class for other classes.
    Its Implementation is done only in sub classes
    A Class can inherit one abstract class and must override all its abstract methods etc.
Example:

public abstract class WashingMachine
{
   public WashingMachine()            //Implemented method
   {
      // Code to initialize the class goes here.
   }

   abstract public void Wash();            //Un Implemented method
   abstract public void Rinse(int loadSize);    //Un Implemented method
   abstract public long Spin(int speed);        //Un Implemented method
}

implementation of each abstract (Must Override) method in that class, and each implemented method must
receive the same number and type of arguments, and have the same return value,
as the method specified in the abstract class

public class MyWashingMachine : WashingMachine
{
   public MyWashingMachine()
   { 
      // Initialization code goes here.   
   }

   override public void Wash()
   {
      // Wash code goes here.
   }

   override public void Rinse(int loadSize)
   {
      // Rinse code goes here.
   }

   override public long Spin(int speed)
   {
      // Spin code goes here.
   }
}

Wednesday 10 August 2011

Polymorphism in C sharp

Polymorphism in C sharp:

The word Polymorphism means MANY FORMS.
Ability to show more than one form.

Polymorphism is of  TWO types;
1. Complietime polymorphism (nothing but Method Overloading)
    In Method Overloading method takes different input parameters and it do different tasks.
    It's also called early binding.
Example:

class Program

    {

        public class ShapeInformation

        {

            public void Area(float r) // With 1 parameter
            {

                float a = (float)3.14 * r;
                Console.WriteLine("Area of a circle:",a);
            }

            public void Area(float l, float b) // With 2 parameters
            {

                float x = (float)l* b;
                Console.WriteLine("Area of a rectangle: {0}",x);
            }

            public void Area(float a, float b, float c) //3 parameters
            {
                float s = (float)(a*b*c)/2;
                Console.WriteLine("Area of a circle: {0}", s);
            }

        }



        static void Main(string[] args)
        {

            ShapeInformation SI = new ShapeInformation();

            SI.Area(2.0f);
            SI.Area(20.0f,30.0f);
            SI.Area(2.0f,3.0f,4.0f);
            Console.ReadLine();
        }

    }

Note:
        While method overloading overloads must be in different signature,
         name is same and the number of parameters should be varies.

2. Runtime polymorphism (nothing but Method Overriding)
    It's Done using in inheritance and virtual functions. Mthod overriding is called Runtime polymorphism
    It's also called late binding.
    when child class declares a method that has the same type arguments as a method declared by one of its baseclass
Example:
public class ParentObject
{
    public virtual void Draw()
    {
    Console.WriteLine("I am a drawing object:Parent.");
    }
}
public class Child: ParentObject
{
    public override void Draw() //Draw is a base class name overriding in child class
    {
    Console.WriteLine("I am a Triangle:Child.");
    }
}


public class ShapeDemo
{
    public static void Main()
    {
    ParentObject ParentObj = new child();
    ParentObj.Draw();
   
}

Tuesday 9 August 2011

Encapsulation in C Sharp

Encapsulation: Means protect or prevent data from corruption (Nothing but Hiding the data ).
Example With help of Properties:
using System;
public class Grossary
{
    private string item;

    public string Item
    {
     get{ return item; }
     set { item=Value; }
    }
}

Public Class GrossaryMain
{
    public static int Main(string[] args)
    {
    Item Id=new Item();
    id.item="Sugar";
    Console.Writeline("item :{0}",id.item);
    return 0;
    }
}

OutPut :Sugar.
Description:
We can not access the private data outside of the Grossary() class.
so we modified it with help of properties get, set by using method Item().

The above Properties Get is used to return the value.
             Set is used to Set the Value.

Thursday 4 August 2011

Passing Parameter to Crystal Report

   ReportDocument report_crp;
    CrystalReportViewer crv;

crv = new CrystalReportViewer();
            report_crp = new ReportDocument();
            report_crp.Load(Server.MapPath("reportname"));
            #region Parameters passing to rpt file
            //  Passing parametrs
            ParameterValues pvs = new ParameterValues();
            ParameterDiscreteValue pdsv = new ParameterDiscreteValue();
            ParameterFieldDefinitions pfds;
            ParameterFieldDefinition pfd;
            pfds = report_crp.DataDefinition.ParameterFields;
            pfd = pfds["@Param1"];
            pvs = pfd.CurrentValues;
            pdsv = new ParameterDiscreteValue();
            pdsv.Value = Request.QueryString["Param1"].ToString();// "11/06/2010";
            pvs.Add(pdsv);
            pfd.ApplyCurrentValues(pvs);
            pfds = report_crp.DataDefinition.ParameterFields;
            pfd = pfds["@Param2"];
            pvs = pfd.CurrentValues;
            pdsv = new ParameterDiscreteValue();
            pdsv.Value = Request.QueryString["Param2"].ToString();//"7373";
            pvs.Add(pdsv);
            pfd.ApplyCurrentValues(pvs);
            pfds = report_crp.DataDefinition.ParameterFields;
            pfd = pfds["@Param3"];
            pvs = pfd.CurrentValues;
            pdsv = new ParameterDiscreteValue();
            pdsv.Value = Request.QueryString["Param3"].ToString();//"M01";
            pvs.Add(pdsv);
            pfd.ApplyCurrentValues(pvs);
            //End Passing paramentes
            #endregion
            crv.ReportSource = report_crp;
            crv.HasExportButton = true;
            crv.HasToggleGroupTreeButton = true;
            crv.DisplayGroupTree = true;
            crv.HasCrystalLogo = true;
            crv.HasDrillUpButton = true;
            crv.HasViewList = true;
            crv.HasPrintButton = true;