Le site Web ASP.NET ne peut pas voir le fichier .cs dans le dossier App_Code

J'ai donc une ASP.NET site web (pas d'application web), je suis en train de faire dans VS2010 avec C#. Il tourne très bien sur ma machine, mais quand je le télécharge sur le site il est hébergé sur, il ne compile pas: "CS0246: le type ou Le nom d'espace de noms 'DataAccess' n'a pas pu être trouvée (vous manque une directive using ou une référence d'assembly?)"

J'ai été en utilisant la copie fonctionnalités du site web en VS et pas eu de problèmes jusqu'à ce que je voulais mettre ma propre classe dans le dossier App_Code et de l'utiliser. J'ai lu dans d'autres réponses sur la modification de l' .cs propriétés de "Compiler" au lieu de "Contenu", mais il n'y a pas une option pour moi dans les propriétés du fichier... seul le Nom du Fichier, le Chemin d'accès Complet et Personnalisé de l'Outil. Voici le code de la .cs fichier:

using System;
using System.Data;
using System.Data.SqlClient;
using System.Web.Configuration;
///<summary>
///Provides access to SQL Server database. 
///</summary>
///
public class DataAccess
{
//Variables & public properties ***********************************
private string connectionString = "";
private int recordCount = -1;
///<summary>
///Property: gets count of records retrieved or changed 
///</summary>
public int Count
{
get
{
return recordCount;
}
}
//Class constructor is executed when object is initialized ***********
///<summary>
///Connection string name in web.config file is required to initialize DataAccess
///</summary>
///<param name="ConnectionName">Name of web.config connection string</param>
public DataAccess(string ConnectionName)
{
if (WebConfigurationManager.ConnectionStrings[ConnectionName] == null) {
throw new Exception("Cannot find connection string named '" +
ConnectionName + "' in web.config");
}
//Get connection string from web.config.
connectionString = WebConfigurationManager.ConnectionStrings[ConnectionName].ConnectionString;
}
///<summary>
///Executes SELECT statement and returns results in dataTable
///</summary>
///<param name="SQL">Select SQL statement</param>
///<returns></returns>
public DataTable FillDataTable(string SQL)
{
SqlConnection _objConn = new SqlConnection(connectionString);
SqlDataAdapter objAdapter = new SqlDataAdapter(SQL, _objConn);
DataTable dt = new DataTable();
try {
objAdapter.Fill(dt);
}
catch (SqlException ex) {
throw new Exception("Error in SQL:" + SQL, ex);
}
catch (Exception ex) {
throw ex; //Bubbling exception up to parent class
}
finally {
_objConn.Close();
}
recordCount = dt.Rows.Count;
return dt;
}
///<summary>
///Executes "non-query" SQL statements (insert, update, delete)
///</summary>
///<param name="SQL">insert, update or delete</param>
///<returns>Number of records affected</returns>
public int ExecuteNonQuery(string SQL)
{
SqlConnection _objConn = new SqlConnection(connectionString);
try {
_objConn.Open();
SqlCommand objCmd = new SqlCommand(SQL, _objConn);
recordCount = objCmd.ExecuteNonQuery();
}
catch (SqlException ex) {
throw new Exception("Error in SQL:" + SQL, ex);
}
catch (Exception ex) {
throw new Exception(ex.Message); //Rethrowing exception up to parent class
}
finally { _objConn.Close(); }
return recordCount;
}
public int ExecuteScalar(String SQL)
{
SqlConnection _objConn = new SqlConnection(connectionString);
int intID;
try {
_objConn.Open();
SqlCommand objCmd = new SqlCommand(SQL, _objConn);
intID = Convert.ToInt32(objCmd.ExecuteScalar());
}
catch (SqlException ex) {
throw new Exception("Error in SQL:" + SQL, ex);
}
catch (Exception ex) {
throw new Exception(ex.Message); //Rethrowing exception up to parent class
}
finally { _objConn.Close(); }
return intID;
}
}//end class

Et de ma page:

<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void Page_Load(object sender, EventArgs e)
{
//Initialize dataAccess class
DataAccess myDA = new DataAccess("A05Customers");
//Populate dataTable and bind to GridView Control
string strSQL = "Select * from tblCustomers";
gvCustomers.DataSource = myDA.FillDataTable(strSQL);
gvCustomers.DataBind();
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>GridView</title>
</head>
<body>
<form id="form1" runat="server">
<div align="center" style="font-family: Verdana">
<h2>GridView</h2>
<hr style="color: #0000FF" width="800" />
<br />
<asp:GridView ID="gvCustomers" runat="server" BackColor="#FFFFCC" BorderColor="#336699" BorderStyle="Inset" BorderWidth="5px" CellPadding="2" CellSpacing="4" />
<br />
</div>
</form>
</body>
</html>

Merci pour votre aide!

source d'informationauteur yeratowel