TagPrefix containing StrongKey
I'm debbuging a web application that has a WebSite and a class library containg web controls. My WebSite, at design-time references the assembly with a Project Reference and Visual Studio automatically populates the Toolbox with the controls found in my class library.
The problem is : When I drag them to the ASPx designer, Visual Studio automatically creates a TagPrefix ignoring the my class library's strong key. This is a problem for me because when I publish this website, this class library will be the Global Assembly Cache and it won't be found if the TagPrefix doesn't properly reference it.
Any idea about how to force visual studio to consider my assembly's stron开发者_运维问答g key when creating the tag prefix?
Thanks.
Have you added the TagPrefix attribute to your class library?
From MSDN
[assembly:TagPrefix("CustomControls", "custom")]
namespace CustomControls
{
// Simple custom control
public class MyCS_Control : Control
You should also check out the toolbox data attribute
namespace CustomControls
{
[ ToolboxData("<{0}:MyLabel Text='MyLabel' BorderColor='Yellow' BackColor='Magenta' BorderWidth = '10' runat='server'></{0}:MyLabel>") ]
public class MyLabel : Label
{
And lastly, register your assemblies in the web.config
<system.web>
...
<pages>
...
<controls>
...
<add tagPrefix="yourPrefix"
namespace="MyAssembly.Some.Namespace"
assembly="MyAssembly" />
...
Rebuild your project then drag one of your controls onto the page.
精彩评论