Sunday, April 15, 2012

how to create and use shared assembly in asp.net

Shared Assembly are module level dynamic link libraries,the shared assembly DLL file features we can distribute in all .net technologies.It sharing the features from he assembly folder.This folder located in c:/windows(xp) The shared assembly DLL files having unique version command SN option -K .The command option created one file SNK strong name key ,which is located in DLL.The exe file doesn't communicate directly with DLL

Strong Name Key file:SNK file is the communicator between .net exe file of shared assembly,The strong Name Key file having unique version,this file reference we have to add in the Assembly info.cs file

SN:it is the .net frame work DOS command,using the command we can get unique version from the OS

SN command Options -K:Using this option we can create the key file ,that file maintain the unique version after creating the shard assembly dll file with unique version.Manually we have to install DLL into the Assembly folder

Gacutil command option -i:Using this option we can install the shared assembly dll file into the assemble folder

 -U: Using this option we can uninstall shared assembly DLL file from the Assembly folder Example:
Got to class library project module
namespace classlibrary 1
{
public class class1
{
public string addstr(string s1,string s2)
{
return== s1+s2;
}
}}
Creatiing SNK file :Open vs.net command prompt by clicking start menu,msvs2010,vstools click on command prompt go to dll file location my computer-->d drive-->test-->debug In the VScommandPrompt cd copy the path -->sn -k abc.snk In debug folder created on file "abc".The adding abc.snk file reference in the assembl info .cs file

Assemblyinfo.cs:This file is used to give the information about meta data of dll file.Here we can also give title,description nd version information to dll file Tp open the Assembly info file go to solution explorer,extract properties folder ,double click on the asemblyinfo.cs file *Build the class library project,getting dll file *Installing shared assembly dll file into assembly folder *Adding shared Assembly reference -->click on project menu -->add reference,select browse tab--goto project location--select the dll file ==click on ok
using classlibrary1
button_click
{
class obj1=new class1();
string str;
str=obj.addstr("csharp",".net");
messageBox.show(str);
}
Post a Comment

Bel