Creating a Web Part Using Global Assembly Cache (GAC)

2        Creating a Web Part Using Global Assembly Cache (GAC)

 In this method, we will only describe the different steps with respect to the previous method. Follow the steps 1.1 to 1.4 same as in the previous post and build the project. The code of the project is shown in the figure below:

   

3-1.jpg

2.1   Signing the Assembly

 The next step is of signing the assembly. To do this, you have to move to the properties window of the project as illustrated in the step 1.5. Select the Signing Pane of the properties window and check the “Sign the Assembly” option. Select <New…> from the “Choose a strong name key file:” and give the name that you desired. In our case, we named it “HELLOWORLD” as shown in the figure below:  

3-21.jpg

 

2.2  Build the project

 We will build by pressing F6 or clicking on Build in the tolls menu and then clicking on Build Solution. Build will generate the file in the debug directory of the project. 

2.3  Copying into GAC

 The file HELLASSEMBLY.dll can be found in the debug folder whose path in our case is as fellow C:\Documents and Settings\ffaiz\My Documents\Visual Studio 2005\Projects\HELLOGAC\HELLOGAC\bin\Debug. Depending upon your installation, you can find the file in the debug folder. Copy the file “HELLOASSEMBLY.dll” from this folder and paste it in the GAC folder which is normally found at C:\WINDOWS\assembly. After copying the file in the GAC, copy the public token key as encircled in the figure below: 

  

3-3.jpg

2.4  Adding Reference

 We have to add the reference to the web.config. The file will be located in the folder created by MOSS. In our case, the path of the file is C:\Inetpub\wwwroot\wss\VirtualDirectories\80. We will open the file in the Visual Studio and go to the tag <SafeControls>. Here we will add a new entry for our web part in the <SafeControls> tag which is <SafeControl Assembly=”HELLOASSEMBLY, Version=1.0.0.0, Culture=neutral, PublicKeyToken=ae23d1c2ca8c8a6e” Namespace=”HELLOGAC” TypeName=”*” Safe=”True” />, encircled in the figure below:

 

3-4.jpg

Note here that the public Key Token copied from the GAC has been added in the <SafeControl> tag of the Assembly. 

Rest of the steps is same as that of the previous post. Follow those steps to add the web part in the site. 

Advertisements

1 Comment »

  1. fw said

    good

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: