Powered by Blogger.

Sunday, February 16, 2014

How to Generate a Strong Name for the Assembly and How to Build the Assembly and Add it to the Global Assembly Cache ?



Generate a Strong Name for the Assembly
Assemblies that host serviced components must be strong named. This procedure generates a public-private key pair used to strong name the assembly.
To generate a strong name for the assembly
Step-1:Open a command window and go to the current project directory.

Step-2:Use the sn.exe utility to generate a key file that contains a public-private key pair.
sn.exe -k RajSimpleComponent.snk

Step-3:In Visual Studio, open assemblyinfo.cs.

Step-4:Locate the [AssemblyKeyFile] attribute and modify it to reference the key file in the project directory as follows.
[assembly: AssemblyKeyFile(@"..\..\RajSimpleComponent.snk")]

Build the Assembly and Add it to the Global Assembly Cache

This procedure builds the assembly that contains the serviced component and then adds it to the global assembly cache. Serviced components should generally be registered in the global assembly cache because they are system level resources.
To build the assembly and add it to the global assembly cache
Step-1:On the Build menu, click Build Solution.

Step-2:Return to the command window and run the following command to add the assembly to the global assembly cache.
gacutil –i bin\debug\RajtestCom.dll



0 comments

Post a Comment