Sharing a User Control across Web Applications
page 3 of 8
by Thomas Z.
Feedback
Average Rating: This article has not yet been rated.
Views (Total / Last 10 Days): 35329/ 78

Sharing the Code Behind Assembly of Our User Controls Library

As we want to share our library across multiple web applications we must register the assembly that holds the code behind of our user control in the GAC (Global Assembly Cache). In order to register our assembly in the GAC we must follow several steps.

First, generate a strong name key for it and set the "AssemblyKeyFile" attribute in the "assemblyInfo.cs" of our project with the keys filename and path. We can generate a key using the DOS sn.exe utility.

sn.exe -k ControlsLibraryKeys.snk

Next, we build our solution and to register our assembly in the gac we choose to either drag and drop it directly in the \WINNT\assembly folder or use the following DOS command.

Gacutil.exe -i yourassemblypath

We must also inform the ASPX compiler that we want him to check for our new shared assembly. To do that we need to edit the machine.config. This file contains most .Net configuration of our local machine. You can find it in the following directory:

\WINNT\Microsoft.net\FrameWork\YourVersion\CONFIG

Load the file in a plain text editor and search for the <assemblies> element, add the following child element to it :

<add assembly="UserControlsLibrary, Version=1.0.0.0, Culture=neutral, PublicKeyToken=29f4c43ca2dde360"/>

These values might change depending on your current settings. You can get the current publicKeyToken of your assembly from the \WINNT\assembly folder.


View Entire Article

User Comments

Title: require same solution for .net 2.0   
Name: Mital
Date: 2007-10-24 8:09:33 AM
Comment:
To Graham,

as you said u have published a newer verion for .net 2, but that link is not working and I want it urgently Please help me.
Thanks in advance
Title: That's Great, Really.   
Name: Shahzad
Date: 2006-12-14 11:45:22 AM
Comment:
Thanks very much buddy. Actually, i was looking for a solution to manipulate a control all dynamically, and after a lot of search i found this article, it helped me a lot.
Thanks and keep it up!
Title: A newer solution to the problem   
Name: Graham
Date: 2006-07-26 7:45:17 AM
Comment:
I've just posted a new solution for .Net 2 that allows you to include UserControls, Pages and MasterPages in a single Web Application Project library that can be distributed easily.

Its quick and easy to set up, there a description of how it works and a solution download that demonstrates everything working at,
http://www.nearasmakesnomatter.co.uk/wapul.htm
Title: Thanks   
Name: MG
Date: 2006-02-08 1:32:39 PM
Comment:
The ~ trick is great. I was struggling with virtual directories. Thanks for the help.

Product Spotlight
Product Spotlight 





Community Advice: ASP | SQL | XML | Regular Expressions | Windows


©Copyright 1998-2024 ASPAlliance.com  |  Page Processed at 2024-05-08 12:12:06 PM  AspAlliance Recent Articles RSS Feed
About ASPAlliance | Newsgroups | Advertise | Authors | Email Lists | Feedback | Link To Us | Privacy | Search