views:

1252

answers:

3

All of a sudden our VB ASP.Net 2.0 WebSite Project started complaining that Exception was not defined.

I have discovered that if I add "Imports System" to the header, or explicitly use System.Exception that it works, but this error permeates a lot of other System descendants like the Data namespace, and the DateTime object. We have hundreds and hundreds of pages, so adding Imports System to all of them not only would be time consuming, but it seems like a band-aid fix to the problem.

I have checked the Project->Property Pages->References, and the web.config file, and the assembly is imported into the project, it is just not being "Auto Imported" into the Class Files like it USUALLY is. Note this does not JUST affect CodeBehind, but All className.vb files.

I would like to fix this problem, but more importantly would like to understand what could cause the System namespace to all of a sudden stop being auto imported. There is obviously some file change that caused this, as my co-worker started seeing the problem this morning after he did a Full-Get on the project.

MORE: The Web.Config file located in the Windows\Microsoft.Net...\Config\Web.Config file does have the , and System is added. Adding the tags, and adding System to the LOCAL web.config did nothing to mitigate the problem.

Any help would be appreciated. First SO Question, so I hope I was descriptive enough.

+3  A: 

Alter the Web.config file and add the namespaces you want under the <pages> tag in <system.web>:

<pages>
 <namespaces>
  <add namespace="System"/>
  <add namespace="System.Data"/>
  <add namespace="System.Web"/>
  <add namespace="System.Web.UI"/>
  <add namespace="System.Xml"/>
  <add namespace="System.Data.SqlClient"/>
  <add namespace="System.Collections.Generic"/>
 </namespaces>
</pages>
Mehrdad Afshari
Yes this set should be present in the Web.Config in the framework by default.
AnthonyWJones
The <pages><namespaces> tag is there in web.config that is in the CONFIG folder of the framework folder in the Windows folder. Furthermore, Adding it to the local web.config did not fix the problem.
AtlSteve
Could you mention the exact error messages?
Mehrdad Afshari
+1  A: 

Check you section in your web.config, does it contain ?

If so it shouldn't be there if not, check the Framework/CONFIG folder under Microsoft.NET in the windows folder. In the section in the web.config in that folder there should be:-

<add namespace="System">

I can't imagine why anyone would remove it though

AnthonyWJones
A: 

You could check to see if mscorlib is being ignored in your project build settings.

Project -> YourProject Properties -> Build -> Advanced, then make sure that "Do not reference mscorlib.dll" is unchecked.

chills42
I'm working this project in Visual Studio 2005, and do not see an advanced button on the Build page in the "Project Properties" tabsheet. This seems like a promising answer, but I cannot find the option you describe. Thanks.
AtlSteve
I added it to the question, but I will state here, too, that this project is a "website" not a "web project," so it doesn't have "Project Properties" it has "Property Pages"...which may be why I can't access the mscrolib.dll setting you discuss.
AtlSteve