1

See the code below:

Imports System.Web.UI

Public Class TTDefault

   Inherits Page

   Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
      ' Some code goes here    
   End Sub

End Class

The background compiler generates an Imports statement is unnecessary. message. If I remove it or comment it out, the background compiler shows no errors. However, when I run, the compiler output says:

5>C:\Work\TimeTrack\TimeTrack\Default.aspx.vb(11,13): error BC30002: Type 'Page' is not defined.
5>C:\Work\TimeTrack\TimeTrack\Default.aspx.vb(13,92): error BC30590: Event 'Load' cannot be found.

...which is what I would expect, considering that the "Imported namespaces" section of the References tab of the project properties has nothing selected. Also, web.config includes this:

   <system.web>
      <pages>
         <namespaces>
            <clear/>
         </namespaces>
      </pages>
   </system.web>

How can I get the compilations to match one another?

Also, if I add this into Web.config instead of specifying the Imports statement:

     <namespaces>
        <add namespace="System.Web.UI"/>
     </namespaces>

...I get the same errors when I compile. However, including the imported namespace on the project properties reference page does make it work.

trw
  • 239
  • 1
  • 11
  • Strange. I can't reproduce it in a simple console app, but I did reproduce if I started from a ASP.NET Web API application. After reproducing it, [this answer](https://stackoverflow.com/a/43162177/3791245) helped fix things. I couldn't tell you _why_ IntelliSense was failing in this way, though. – Sean Skelly Jul 02 '20 at 00:52
  • 1
    @SeanSkelly That didn't fix it, but it did lead to a fix. I ended up deleting the entire .vs folder under the project, which contained the hidden .suo file. Deleting .suo wasn't enough. But once VS was forced to rebuild the whole .vs folder, it worked properly. Thank you. – trw Jul 02 '20 at 14:19

0 Answers0