Hello, I am applying a new version of an assembly to a web project and have found that I am going to have to replace about 500 instances of the Register Assembly tag at the top of each web control. I considered registering it in the web.config but when I try this and remove the "Register" tag from the controls, i receive the "unrecognized tag prefix" error as well as losing intellisense for that tag. I have not GAC'ed the assemblies but i didnt think that would a problem. What am I missing here? Thanks in advance for any help.
Are you sure that you are building the config file correctly? Rick Strahl just wrote an excelent article on this very issue:
http://www.west-wind.com/WebLog/posts/753705.aspx
Usually when you embed a custom control into a page you need to add a @Register tag like so:
<%@ Page language="c#" Inherits="Westwind.WebToolkit.MessageDisplay"
CodeBehind="MessageDisplay.aspx.cs"
enableViewState="false" AutoEventWireup="True"
MasterPageFile="~/WestWindWebToolkit.master"
%>
<%@ Register Assembly="Westwind.Web" Namespace="Westwind.Web.Controls" TagPrefix="ww" %>
in order to get a control to work in the page and show up with Intellisense. If you’re using the visual designer to drop controls you probably won’t notice this requirement because the designer automatically adds the assembly and namespace dependency for you into the page. However if you work in markup only as I do mostly, it’s often annoying to first have to register the control on the top of the page and then go back to actually embedding the control into the page to get Intellisense.
An easier and application global way to do this is to declare your namespaces and control tags directly in web.config and have them apply globally:
<system.web> <pages>
<namespaces>
<add namespace="System.IO" />
<add namespace="System.Text" />
<add namespace="Westwind.Utilities" />
<add namespace="Westwind.Web.Controls" />
</namespaces>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add tagPrefix="ww" namespace="Westwind.Web.Controls" assembly="Westwind.Web" />
</controls>
</pages> <compilation debug="true">
<assemblies>
<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
</system.web>
The controls section is what provides effectively the equivalence of the @Register tag in pages and once you’ve defined the tag prefix there the @Register tag is no longer required in the page.
Hope that Helps,
Jim