Tom Tom - 27 days ago 5
C# Question

visual studio website - lots of random errors but still building?

I have a ASP.NET website written by someone a while ago, I don't think they used VS to build their sites but unfortunately am not sure what they did use.

I open as website and build .. no errors.

As soon as I open up any of the pages or classes the intellisense moans about nearly everything, starting with

Error 25 Statement cannot appear outside of a method body/multiline lambda.

on the using statements but literally errors on everyline. But still builds fine.

Any ideas how I can resolve this? I can still build the site but if I make any real errors I can't tell where they have come from and also I have no intellisense.

Edit-- an example if I open one of the simplest files on the site.

using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class About : System.Web.UI.Page
{

protected void Page_Load(object sender, EventArgs e)
{
Master.bodyClass = "about";
}

}


The error list goes straight to 71 Errors on the single file.

Error 26 Syntax error. PATH\about.aspx 1 PATH\ 1
Error 27 Syntax error. PATH\about.aspx 1 PATH\ 1
Error 28 Syntax error. PATH\about.aspx 1 PATH\ 1
Error 29 'Class' statement must end with a matching 'End Class'. PATH\about.aspx 1 PATH\ 1
Error 30 Declaration expected. PATH\about.aspx 1 PATH\ 1
Error 31 Bracketed identifier is missing closing ']'. PATH\about.aspx 1 PATH\ 1
Error 33 End of statement expected. PATH\about.aspx 1 PATH\ 1
Error 34 Syntax error. PATH\about.aspx 1 PATH\ 1


(to include the first 8 errors, have changed removed the project name / path)

It will still build correctly (the errors don't seem to bother the compiler), but makes it very difficult to work with.

EDIT -

line 1 of the aspx file

<%@ Page MasterPageFile="~/master.master" CodeFile="index.aspx.cs" Inherits="About" %>

Answer

Visual Studio thinks that your ASPX files are VB.Net rather than C#.

Change the default language in Web.config (<compilation defaultLanguage="C#">).