NOTES

Tuesday 28 June 2011

C#

Reflection

            Assembly Contain the four Filed

·         Main-Fest
·         Matadata
·         IL
·         REsources


MANI-FEST
        An assembly manifest contains The first four items
·          the assembly name,
·          version number,
·          Culture
·          strong name information - make up the assembly's identity.

 Assembly name: A text string specifying the assembly's name.
 Version number: A major and minor version number, and a revision and build number. The common language runtime uses these numbers to enforce version policy.

 Culture: Information on the culture or language the assembly supports. This information should be used only to designate an assembly as a satellite assembly containing culture- or languagespecific information. (An assembly with culture information is automatically assumed to be a satellite assembly.)

 Strong name information: The public key from the publisher if the assembly has been given a strong name.







Create Shared Assembly

· First Create The  Strong Key Name
  Syntax Is:
                  C:\     Sn –k a.snk     
                 by Defualt Store In C:\\

·Second Create the  .cs file
using System;
using System.Reflection;                                                                      
[assembly:AssemblyKeyFile("c:\\amit\\a.snk")]

public class amit
{
public string show()
{
return "AMIT KUMAR GUPTA";
}

public int add()
{
int i,j,k;
Console.WriteLine("enter first number");
i=Convert.ToInt32(Console.ReadLine());
Console.WriteLine("enter Second number");
j=Convert.ToInt32(Console.ReadLine());
k=i+j;
return k;
}
}

·        File  Save in Strong Key pleace Let File Name IS shar.cs
·        Third .cs File Convert Into .Dll Fill
     Syntax Is:
                  C:\ csc  /t:library shar.cs


·  Fourth Mapping the .Dll file in Cache
   Syntax Is :
                   C:\gacutil  /I shar.dll
·        Fifth create an Other .cs File

using System;
public class a
public static void Main()
{
amit a1=new amit();
Console.WriteLine(a1.show());
Console.WriteLine(a1.add());
}
}

·  File Save  Any Location Let File Name Is      shar1.cs And Save In D:\\

· Compile The shar1.css And Take The Shar.Dll File Reference
  Syntax is:
                    D:\ csc /r  c:\\shar.dll shar1.cs

·  After the Compile Use Only file Name
   Syntax Is  :
                    D:\ Shar1

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home