我的文件结构如下图所示
我的项目名称为myIGNOU
,App_Code
文件夹中所有这些文件中的类类都写在myIGNOU
namespace
中。
但有些事情让我感到恼火,因为我可以从AppSettings.cs
文件中的Code2.cs
文件访问类,但无法访问AppSettings.cs
中Code1.cs
的相同类。我尝试只交换Code1.cs
和Code2.cs
的文件名,但没有运气,仍然是非常相同的行为。我也尝试在同一个文件夹中添加另一个类(在单独的文件中),但我仍然无法在这个新创建的类中访问任何类AppSettings.cs
文件。
当我在每个文件中有一些类(全部公开)时,为什么没有按钮来展开任何其他文件而只是Code1.cs
..?
我错过了什么..?我也尝试重命名App_Code
文件夹但又没有运气。
虽然可以在其余类中访问所有类文件Code1.cs
。
我认为如果输入任何错误的lasdk;adj.j
,我就不会编译这三个文件中的任何一个。我不会得到任何编译时错误。但我在运行时得到Compilation Error
。对于不在此文件夹中的其他文件,例如Default.aspx.cs
,情况也是如此。为此,我将在编译时遇到错误。
这是代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
namespace myIGNOU
{
public static class AppSettings
{
//public static string ConnectionString { get { return "Data Source = .; Initial Catalog = SMR; Integrated Security = True;"; } }
//public static string ConnectionString2 { get { return "Data Source = .; Initial Catalog = shashwat; Integrated Security = True;"; } }
public static string ConnectionString { get { return "Data Source=IDCSQL2.znetlive.com,1234;Initial Catalog=smrbobdn;User Id=shashwat;Password=xxxx;"; } }
public static string ConnectionString2 { get { return "Data Source=IDCSQL2.znetlive.com,1234;Initial Catalog=shashwat;User Id=shashwat;Password=xxxx;"; } }
public static string ConStr1 { get { return "Data Source=.; Initial Catalog=myIGNOU; Integrated Security=true;"; } }
public static DateTime Now { get { return DateTime.Now.AddMinutes(0); } }
}
}
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.IO;
using System.Net;
namespace myIGNOU
{
public class Student
{
public Student(string enrollmentNumber)
{
EN = enrollmentNumber;
}
public bool LoadFromDB()
{
bool ret = false;
SqlCommand com = new SqlCommand("SELECT * FROM StudentInfo WHERE EN = @en", new SqlConnection());
return ret;
}
public string EN { get; set; }
public string Name { get; private set; }
public string FatherName { get; private set; }
public string Program { get; private set; }
public string Address { get; private set; }
public string Mobile { get; set; }
public string Email { get; set; }
public uint RC { get; private set; }
public uint SC { get; private set; }
public uint AdmissionYear { get; private set; }
public uint AdmissionValid { get; private set; }
public uint UpdatedOn { get; private set; }
}
public class HttpRequest
{
string GetPageAsString(string path, string method, string dataToPost)
{
return "...";
}
}
public class Program
{
}
public class Semester
{
}
public class Course
{
}
}
using System.Data.SqlClient;
using System.Text.RegularExpressions;
using System.Net.Mail;
namespace myIGNOU
{
public class CustomHttpRequest
{
}
public class Emails
{
public static MailAddressCollection GetAllEmails()
{
MailAddressCollection cc = new MailAddressCollection();
SqlCommand com = new SqlCommand("SELECT Email from myignou", new SqlConnection(AppSettings.ConnectionString));
com.Connection.Open();
SqlDataReader dr = com.ExecuteReader();
while (dr.Read())
{
cc.Add(dr[0].ToString());
}
com.Connection.Close();
return cc;
}
}
public class RegexUtilities
{
public static bool IsValidEmail(string strIn)
{
// Return true if strIn is in valid e-mail format.
return Regex.IsMatch(strIn,
@"^(?("")(""[^""]+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))" +
@"(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$");
}
}
}