I have an ASP.NET web application project which references another project called ModusCore (or Modus.Core). We've had a variety of controls that use ModusCore up until now with no problem, but there's one I created lately that's been causing trouble. Here's the code:
public class PortalLinkNew : WebControl
{
public string Text { get; set; }
public bool AllowPush { get; set; }
public PortalLinkNew()
{
AllowPush = true;
}
public IChannelRequest ChannelRequest { get; set; }
protected override HtmlTextWriterTag TagKey
{
get { return HtmlTextWriterTag.A; }
}
protected override void AddAttributesToRender(HtmlTextWriter writer)
{
try
{
base.AddAttributesToRender(writer);
if (DesignMode || Page == null || !(Page is IPortalPage))
{
return;
}
string href = "/";
if (ChannelRequest != null)
{
var portalPage = (IPortalPage)Page;
href = portalPage.Module.PortalRouter.GetLinkUrl(portalPage, ChannelRequest, AllowPush);
}
writer.AddAttribute(HtmlTextWriterAttribute.Href, href);
}
catch (Exception)
{
}
}
public override void RenderEndTag(HtmlTextWriter writer)
{
writer.Write(Text);
base.RenderEndTag(writer);
}
}
In the above code, IPortalPage
and IChannelRequest
are interfaces defined in Modus.Core.
My intent is to use this control in my code as follows:
<tnl:PortalLinkNew ID="CancelButton" runat="server" Text="Cancel" OnInit="CancelButton_Init" />
This actually compiles and runs without a problem, but when I'm editing the page (source view) in Visual Studio 2008, I get the following warning:
Generation of designer file failed: Could not load file or assembly 'Modus.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
As it says, it doesn't regenerate the designer file, meaning any attempt to refer to the CancelButton
control in code-behind results in a compiler error. Following advice I've found online, I've tried deleting the corresponding .ascx.designer.cs file and using "Convert to Web Application" on that page, but it tells me that it cannot rebuild the designer file for the same reason mentioned above.
I've tried everything I can think of: cleaning the solution, restarting Visual Studio, rebooting my computer, deleting the code directory and pulling it fresh from the repository, removing and re-adding the project and dll references, etc. The same problem occurs on multiple computers I use.
How can I get the VS designer to stop failing?