Sunday, March 9, 2014

Implementation of Shared Assemblies


Implementation of Shared Assemblies

Create a Class Library Project.

  • Create a new Class Library project.
  • Write the required code in the project.

Create a strong name key.

  • Right click on the project in the Solution Explorer and choose Properties.
  • In the project properties, select the check box Sign the assembly.
  • In the Choose a strong name key file‖ drop down, select <New> option.
  • In the Create strong name key‖ dialog box, enter the name of the strong name key file.
  • If password security is not required, uncheck the Protect my key file with a password checkbox.
  • Click on OK.

Customize the “Assembly Information” (AssemblyInfo.cs).

  • This is optional step.
  • To change the additional details of the assembly like displayed name, version, company, copy right, description etc., open “AssemblyInfo.cs” file from the Properties folder in the Solution Explorer.

Generate the DLL File.

  • Build the class library project.
  • Then the .dll‖ file will be generated in the bin\debug folder of your class library project.

Write the assembly into GAC (Global Assembly Cache).

  • Open the following folder.
  • C:\Windows\Assembly
  • Drag and drop the ―.DLL file‖ from ―bin\Debug‖ folder into the
  • c:\windows\assembly folder.
  • After dragging, the name of your shared assembly will appear in the existing list.
  • Now, the shared assembly is ready. The rest of your work involved with the usage of the shared assembly.
Invoke the Shared Assembly.
  • Create the executable project (Console application / windows application).
  • Click on Project – Add Reference.
  • Click on Browse tab.
  • Open the class library project‘s bin\Debug folder.
  • Select the dll file and click on OK.
  • Then the reference of the selected shared assembly will be added to the current project.
  • Then you can construct objects for the required class in the class library and perform required activities on that.

No comments:

Post a Comment

Flag Counter