views:

35

answers:

2

The problem is that I have to hit build on my website application multiple times to get all the errors to go away, eventually it will build successfully.

But, i get several messages "label, button, etc does not exist in context". If I click on the file, it corrects itself and disappears. If I click build again it corrects.

I am looking for:

  1. Clear explanation of problem
  2. A fix that works while keeping my same model which is website and not project model
A: 

I know you asked for a clear explanation... so how about Visual Studio isn't perfect and still has issues?

A fix thats worked for me:

This issue has happened to me before in large web projects where my dependency tree is pretty large, though I'm sure it can happen in other situations. To fix it I right click the solution and do a "Clean Solution", then I do a "Rebuild Solution". Usually this will fix it for me.

If not then I do the Cleaning step and then go through, starting at your base proejct, and build them one at a time. Usually this will fix it for a while (yes, I undestand the pain of doing this which is why I grouped my projects into Solution folders and just build those in their logical groups instead). Hope that helps.

Patricker
A: 

Are you building in debug or release mode? I ask because there are differences between these and some build errors only occur in one or the other (usually the bug is in release mode). A quick web search for something like "debug vs release build" will give you some insight.

On a project I worked on a while back I found early on that I had referential problems in release mode that didn't exist in debug mode. I had placed some user controls and web forms in sub-directories in my Website project. The problem was that a web form in one subdirectory used a user control in another subdirectory, and a web form in that subdirectory used a user control in the first subdirectory, thus creating a circular reference between these directories. Does this make sense?

It was something like the following.

Organisations\OrgDetails.aspx -> Departments\DeptartmentSearch.ascx Departments\DeptartmentDetails.aspx -> Organisations\OrganisationSearch.ascx

The controls were in the same project so this shouldn't have been a problem, but Visual Studio complained about not being able to reference one of them when I ran the build in Release mode! It seems that while it was building code in the first directory it was trying to reference the code in the second directory, but the second directory hadn't yet been built!

I think this is a bug with release builds for website projects. I've had no such problems with other project types.

Sam