How to create shared assemblies in Aspnet
Hi friends, in this article I would like to explain creation of shared assembly.
Let’s start with, what is an assembly..?
In simple, Assembly is unit of deployment like EXE or a DLL.it contains one or more files like dll,exe’s,html files etc…,
Now come to the main point what is an shared assembly..?
Overview:
-->All the predefined assemblies are shared assemblies
-->Shared assemblies need to be registered with GAC (Global Assembly Cache)
-->C:\Windows\Assembly folder is called as GAC
-->A DLL which is registered with GAC is called as Shared Assembly
-->A DLL which contains strong name can be registered as shared assembly
-->Strong name provides unique identifier to the assembly which is also called as public key token
-->Syntax to create strong name:
sn –k filename.snk
-->A DLL with strong name can be registered as shared assembly with the help of gacutil tool
Syntax:
gacutil –I dllfilename
Simple steps to create a shared assembly
First open the visual studio 2005
Next select the class library project and change the name as firstsharedprogram.
Next,write the below code
Next we have to create a strong name
For this,open the .Net command prompt and type the following code
Next,we have to integrate the xyz.snk with our project that is firstsharedprogram
For this, open the project and click on the firstsharedprogram properties,
Next click on the signing next click on the checkbox of “sign the assembly”
Next select the Browse from combo box then choose xyz.snk
Next,Build the project
For this open the .Net command project
Now firstsharedprogram.dll is registered in with GAC.so now we can use this assembly with any assembly
That’s it…..Friends
Let’s start with, what is an assembly..?
In simple, Assembly is unit of deployment like EXE or a DLL.it contains one or more files like dll,exe’s,html files etc…,
Now come to the main point what is an shared assembly..?
Overview:
-->All the predefined assemblies are shared assemblies
-->Shared assemblies need to be registered with GAC (Global Assembly Cache)
-->C:\Windows\Assembly folder is called as GAC
-->A DLL which is registered with GAC is called as Shared Assembly
-->A DLL which contains strong name can be registered as shared assembly
-->Strong name provides unique identifier to the assembly which is also called as public key token
-->Syntax to create strong name:
sn –k filename.snk
-->A DLL with strong name can be registered as shared assembly with the help of gacutil tool
Syntax:
gacutil –I dllfilename
Simple steps to create a shared assembly
First open the visual studio 2005
Next select the class library project and change the name as firstsharedprogram.
Next,write the below code
Using System.Data; Using system.Data.sqlclient; Namespace firstsharedprogram { Public class check { Public static Datatable GetData(String connectionstring,string tabelname) { String query=”select * from” +tablename; Sqlconnection con=new sqlconnection (connectionstring); SqlDataAdapter da=new sqlDataAdapter(query,con); Dataset ds=new Dataset (); da.fill(ds,”newtablename”); Datatable dt=new Datatable[“newtablename”]; Return dt; }//close get data }//Test Class }//Close namespaceNext,save the file and minimize it
Next we have to create a strong name
For this,open the .Net command prompt and type the following code
C :> cd D:\Firstapplication\ firstsharedprogram\bin\debug D:\Firstapplication\ firstsharedprogram\bin\debug > sn –k xyz.snk
Next,we have to integrate the xyz.snk with our project that is firstsharedprogram
For this, open the project and click on the firstsharedprogram properties,
Next click on the signing next click on the checkbox of “sign the assembly”
Next select the Browse from combo box then choose xyz.snk
Next,Build the project
For this open the .Net command project
D:\Firstapplication\ firstsharedprogram\bin\debuggacutil –I firstsharedprogram.dllOk..its over we are succesfully created the shared assembly
Now firstsharedprogram.dll is registered in with GAC.so now we can use this assembly with any assembly
That’s it…..Friends
Labels: .Net Tutorials, C#, CSharp, Tanisha
6 Comments:
This is not an appropriate font for an article with code...
Thanks for sharing..i changed the font,i think its look better..
Nice explanation...Good
Thanks for sharing
Welcome
Nice explanation...Good
Post a Comment
Subscribe to Post Comments [Atom]
<< Home