error CS1061: 'class name' does not contain a definition for 'some property' and no extension method 'some property' accepting a first argument of type 'class name' could be found (are you missing a using directive or an assembly reference?)
Tuesday, October 13, 2009 11:10 PMHi, all?
I've been used TFS almost 2 years now and contributed TF auto build adaption for my company. I'd like to share something with you all a particular error I had headache with and today I finally found out why.
Here is the synario. A developer added a new user control into a solution named like "register.ascx" under a folder called, "UControl". Then, by default, the user control gets created and the partial class name is "UControl_register" in its code behind file and Inherits in the directive at the user control page. The developer rename partial class name and inherits to "register". I don't know why. Maybe the partial class name is too long or something borthers and have no idea why the developer renamed it. Now, the developer add an aspx page, "register.aspx" page adding the register.ascx. Ended being both aspx and user control pages are usinig the same partial class name "register".
The thing is during the manual compile, there is no warning or error at all and the developer think that the project is buildable and checked in the files into the source control. I ran the auto build and keep getting the error message, error CS1061: 'register' does not contain a definition for 'some property name' and no extension method 'some property name' accepting a first argument of type 'register'' could be found (are you missing a using directive or an assembly reference?)
Actually during the manual build of the project, there is no error, however, the property can't find its definition because the class name is duplicated.
Obviously, the fix was rename the user control's inherits and partial class name different than the aspx page.
Is this more common mistakes by the developer or can I consider the auto build is just sensative than manual build?
Friday, October 16, 2009 5:36 AMModeratorHi John,
It is a webapplication or website?
I think VS will throw a error when build it . because
public partial class register: System.Web.UI.UserControl
but for register.aspx
public partial class register: System.Web.UI.Page
Their base classes are different and vs will get an error "Partial declarations of 'WebApplication.Default' must not specify different base classes".
Can other user build the project successful locally?
Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread. Sincerely, Ruiz Yi
- Marked As Answer by John Roh Friday, October 16, 2009 5:53 PM
Friday, October 16, 2009 5:53 PMHello, Ruiz?
Unfortunately, most of our project is created as a Website project.
I was able to solve the issue :)
Now I understand what was the issue caused by the developer.
But, until I found the error why, it's took a bit of time because the project was working fine locally. The auto build caught the errors and wants to share it.
what you said is the definately what caused the issue.
Wednesday, December 29, 2010 5:59 AM
Thanks for posting a woderful article.I was struck up with same issue.Your article helped me to resolve it.