I have some WebUserControls that take a parameter to determine how they initialize themselves. However, when I compile the page I get the error
'ControlName' does not contain a constructor that takes '0' arguments
I am not calling it anywhere without an argument, it appears that a reference is being generated in a temporary file. I have another control that doesn't have a empty constructor and it is not requiring one to be created there so it shouldn't have to have one.
The actual error looks like this:
Compiler Error Message: CS1729:
'ControlName' does not contain a constructor that takes '0' arguments
Source Error:
Line 108: private static bool @__initialized; Line 109: Line 110:
[System.Diagnostics.DebuggerNonUserCodeAttribute()] Line 111: public control_ascx() { Line 112:
((global::ControlNamespace)(this)).AppRelativeVirtualPath = "~/ControlName.ascx";Source File: (Path)Local\Temp\Temporary ASP.NET Files\root\1aca8e08\3fab105e\App_Web_controlname.ascx.cdcab7d2.tzm0xzkd.0.cs Line: 110
The control looks like this:
public partial class ControlName: System.Web.UI.UserControl
{
public ControlName(IParameter parameter)
{
Method(parameter);
}
}
EDIT: Based on the comments below it would appear that I have a reference to the control in a designer file...somewhere... All references that I can find are located in code behinds with one exception. The declaration in the .ascx file:
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="ControlName.ascx.cs" Inherits="Control" %>
I thought that this was the culprit but upon further inspection I have other controls which have a similar declaration and do NOT require a default constructor.
How can I find the location where the control is referenced from?
Solution:
I had reference tags
<%@ Reference Control="~/ControlName.ascx" %>
leftover from earlier that apparently count as a designer element.
The answer below does not actually contain this information but is a good description of what the problem was.