I currently have a project setup for a DotNetNuke module. Within this project I have some user control files, which are versioned with TFS using ASP.NET 4.0 and C#.
Currently, the project will build and run fine with no issues. However, ANY change I make to the front end .ascx files of SOME of the user controls in the project will cause the corresponding .ascx.designer.cs to generate ~14 errors stating the following error:
Error ## The type 'ControlClass' already contains a definition for 'SomeControlID' 'Location of ControlName.ascx.designer.cs'
I have not made any other changes to this previously that I could think of that would cause this issues. It just randomly started happening in my project.
I have tried the following:
To make things weirder, when I tried to determine if this could be some sort of syntax issue I did the following and produced these results:
I am not sure why, but every time this project has a change to a few select user controls, the designer files generate with these errors all of a sudden.
These user controls contain complex controls which contain templates full of other controls, etc... However when building these I had no issues with names being the same in different templates and things like that.
I have run out of ideas and have found nothing else to try by searching this issue online.
Any suggestions??
EDIT: It has been suggested that I just manually delete the extra generated controls so that the project will build. After looking into this more deeply I have two issues with this.
First, this will allow the project to build, but I would have to do this EVERY time I update the ASCX, as after I delete them and make another change the control declarations are back.
Second, while this will allow the project to build without issue. It does not run but instead throws the following runtime error:
The base class includes the field 'btnDelete', but its type (System.Web.UI.WebControls.ImageButton) is not compatible with the type of control (Telerik.Web.UI.RadButton).
This error indicates to me that the 'btnDelete' control that I deleted to test this, which was marked as a 'duplicate' error when building is now marked as the incorrect type.
This I believe is due to the fact that there are multiple 'btnDelete' buttons of different types on the user control that is giving me the error. These buttons are contained within different RadGrid controls for their edit/delete templates.
Want to add in my case for this error and how I solved.
Happened with a legacy project that was being upgraded to visual studio 2010 project. In my case had to convert the .aspx files to "Web Applications" for the generation of designer files. In this case, not too sure on specifically what happened but started to get the error mentioned above. Started looking at the variable but it was not defined more than once in the code behind (.cs), aspx page or any other associated controls.
I started to look at the aspx page headers and that is when I noticed the possible problem. I had 2 files with similar names... iABC.aspx (.cs,.designer) and ABC.aspx(.cs,.designer) and in the iABC.aspx header, it was inheriting "ABC"...first sign something was amiss. I changed it to the correct setting "iABC" and then decided to check the class name in the code behind, lo and behold, the class name for the iABC.aspx.cs was set to "class ABC" instead of "class iABC".
Once I fixed up the mess, all was good.
HTH
Dave
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With