0

When I build my website project using visual studio 2016 (or any visual studio for that matter), the compiler gives me an error:

Error when building

However if I go to the code file ResetPassword.aspx the edtEmployeeSurname control is present and it has a runat="server" attribute.

There is also no errors given to me if I open the ResetPassword.aspx.vb code file. (So no red lines under any variable names / Control ID's).

ResetPassword.aspx View

What is really interesting is that the website (Even ResetPassword.aspx) loads correctly from the browser without any issues and I can submit the form.

If I comment out all the code in ResetPassword.aspx.vb then it just finds another control that "Doesn't Exist" and so it carries on with a lot of pages.

All I want to know is:

  • What causes these issues
  • How to fix these issues OR how to determine what the issue is.

If this is a common mistake that some developers make then please help me to formulate a search string to use in google, because most of my search results were obscure or off topic.

Jacques Koekemoer
  • 1,378
  • 5
  • 25
  • 50
  • could be that the browser is loading a previously compiled version, and that what's not compiling in VS is a change to the code. Without seeing the relevant pieces of code there's no way anyone here can realistically suggest a way to fix it. – ADyson Jun 06 '17 at 08:30
  • @ADyson, if you can tell me which code you need to see I can post it, but basically, if I make a change to `ResetPassword.aspx` (Like adding a new textbox) then it will load in the browser, and the vb code will handle any events related to the textbox, so its not loading a previously compiled version, or at least it doesn't appear like it does, I am actively making changes to the website everyday, and all of the changes load correctly. – Jacques Koekemoer Jun 06 '17 at 08:34
  • could just be an error in VS, I guess. Do you get the errors still if you clean the solution, restart VS and then do a brand new build? – ADyson Jun 06 '17 at 08:37
  • I've cleaned the solution, closed and reopened VS then rebuilt the solution, I have also created a new solution and just copied the code files over (excluding bin, aspnet_client etc...), and the issue still remains. – Jacques Koekemoer Jun 06 '17 at 10:25
  • @JacquesKoekemoer - Do you have an App_Code folder? – dbasnett Jun 06 '17 at 11:32
  • @dbasnett I do, all of my DataSets and class's are located in my App_Code folder – Jacques Koekemoer Jun 07 '17 at 07:07

3 Answers3

1

From screenshots, it shows you have 50 errors in your project. There is no way an application will run successfully if you have not set to do so.

You could make application run, even if errors. enter image description here

Check SO post :

Debugging runs even with compiler's errors in Visual Studio

Note:

If you have already cleaned and rebuilt solution, Try running application in other browser or another computer, may be you have data shown from previous successful result.

Tharif
  • 13,794
  • 9
  • 55
  • 77
  • I've tried this solution, and even gone as far as to uninstall and reinstall VS on my machine, however the issue still remains, even if it compiles without showing me the errors (Running the last successful build, it still doesn't attach the debugger to the code because it has errors). – Jacques Koekemoer Jun 15 '17 at 11:32
  • @JacquesKoekemoer have you tried running code in any other system ? – Tharif Jun 16 '17 at 02:21
1

I've run into this sort of thing before and I believe the errors you are seeing are red herrings. They lead me to believe that one of your lower projects where your user controls are defined, or possibly even lower than that, has a possibly unrelated error in it which is causing it to not be built by visual studio, which in turn makes visual studio think your user controls aren't defined.

What I normally do is build the solution and watch the output window. It will build all of your projects individually, the first error you see pop up in the output window is the source of your problem. Everything else you are seeing is a symptom of that original issue. If you fix the first error that shows up in your output then it will either build correctly or you will have to repeat the process with the next error that pops up.

Visual Studio used to order the errors in the error list in the order that they came up during the build but that has changed, I, personally, really preferred the old sorting(I think there is a setting that you can use to get back to the old sorting but I can't think of it off the top of my head).

Mike_OBrien
  • 1,395
  • 15
  • 34
0

Based on the wording of the error, I believe it's possible you are referring to some of these controls outside the code behind of ResetPassword.aspx. The latter part of the message says It may be inaccessible due to its protection level. By default, the backing variable for a control you place on a form is Protected and therefore cannot be seen outside the scope of that control or its inheritance chain.

Fabulous
  • 2,393
  • 2
  • 20
  • 27