Sunday, August 2, 2009

Part III: Step by step procedure of how to install an assembly

Posted on/at 7:31 AM by Admin


Introduction

We have seen in previous articles how to install an assembly using both, the .NET Framework management console and the Global assembly cache tool provided by the NET Framework. Now we will se how to install a strong named assembly with the simplest manner.
We have seen in a previous article  how one can install a given assembly using the .Net Framework management console the Mscorcfg.msc. Now, we proceed to achieve the same goal but using another tool witch is the Global assembly cache tool cagutil.exe provided by the .Net framework.
To do that, follow those steps:
First of all, let us develop a simple assembly. To do that, follow those steps

  • Create a new class library project and name it myAssembly

clip_image001
Figure 1

  • Add this code to the editor

using System;

using System.Collections.Generic;

using System.Text;

using System.Windows.Forms;

namespace myAssembly

{

public class Class1

{

public Class1()

{

MessageBox.Show("You are using myAssembly");

}

}
}

  • Save the project.
    The GAC accepts only assemblies with strong names; there fore it is imperatively recommended to sign the assembly before adding it into GAC, otherwise when adding a none strongly assembly, a message indicates that the new assembly can not be added to the GAC appears and finally the action is failed. So, to sign myAssembly, go to myAssembly properties as shown bellow.

clip_image002
Figure 2

  • Select  the signing tab and then check sign the assembly checkbox

clip_image003
Figure 3

  • Select New in the combo box as shown above. This dialog box appears

clip_image004
Figure 4

  • Enter the key file name with twelve characters, then enter a password with more than six characters and confirm it, then click Ok.
    A file looks like this clip_image005 is added to the application directory with *.snk as an extension witch is a Strong Name Key abbreviation. This file contains a random pair keys and it is provided to sign the assembly. This file can be generated also using the Strong name tool sn.exe provided by .NET framework.
  • Browse to "C:\Windows\assembly" directory witch looks like bellow:

clip_image006
Figure 5

  • Drag the assembly and drop it in this directory, that's all.

0 comments:

Post a Comment

About Me

Developers house is a blog for posting technical articles in different technology like Microsft, Java, Oracle ..etc Microsoft technology includes c#,VB.net,ASP.net,Ajax,SilverLight,TFS,VS.NET 2003,2005,2008,2010 , SQL Server 2000, 2005 , Expression Blend , ...etc I hope it is helpful for all of you and if you are interested to post articles on it, only send me at ahmad.eed@gmail.com