错误显示如下:System.IO.FileNotFoundException: Could not load file or assembly 'FlyingCanada1.SQLServerDAL' or one of its dependencies. The system cannot find the file specified代码如下,我自己测试classname的值是对的,大虾们给看看那里可能有问题,谢谢。namespace FlyingCanada1.DALFactory {   public sealed class DataAccess {        private static readonly string path = ConfigurationManager.AppSettings["WebDAL"];
        private DataAccess() { }
        
        public static FlyingCanada1.IDAL.IAirport CreateAirport() {
            string className = path + ".Airport";
            return (FlyingCanada1.IDAL.IAirport)Assembly.Load(path).CreateInstance(className);
        }
    }
}namespace FlyingCanada1.IDAL
{
    public interface IAirport
    {
        IList<AirportInfo> GetAirports();        AirportInfo GetAirport(string designator);
    }
}
Web.config
<appSettings> <add key="WebDAL" value="FlyingCanada1.SQLServerDAL"/> </appSettings>namespace FlyingCanada1.SQLServerDAL
{
    public class Airport: IAirport
    {
        private const string SQL_SELECT_AIRPORTS = "SELECT  designator, latitude, longitude FROM airportData";
        private const string SQL_SELECT_AIRPORT = "SELECT  designator, latitude, longitude FROM [airportData] WHERE designator = @designator";
        private const string PARM_AIRPORT_DESIGNATOR = "@designator";
 
        public IList<AirportInfo> GetAirports() {      IList<AirportInfo> airports = new List<AirportInfo>();            using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, CommandType.Text, SQL_SELECT_AIRPORTS, null))
            {
                while (rdr.Read()) {
                    AirportInfo airport = new AirportInfo(rdr.GetString(0), rdr.GetDouble(1), rdr.GetDouble(2));
                    airports.Add(airport);
                }
            }  
            return airports;
        }       
        public AirportInfo GetAirport(string designator) {            
            AirportInfo airport = null;            SqlParameter parm = new SqlParameter(PARM_AIRPORT_DESIGNATOR, SqlDbType.VarChar, 5);
            
            parm.Value = designator;           using (SqlDataReader rdr = SqlHelper.ExecuteReader(SqlHelper.ConnectionString, CommandType.Text, SQL_SELECT_AIRPORT, parm)) {
                if (rdr.Read())
                    airport = new AirportInfo(rdr.GetString(0), rdr.GetDouble(1), rdr.GetDouble(2));
                else
                    airport = new AirportInfo();
            }
            return airport;
        }
    }
}

解决方案 »

  1.   

    System.IO.FileNotFoundException: Could not load file or assembly 
    FlyingCanada1.SQLServerDAL
    无法装载文件或程序就是没找到dll“FlyingCanada1.SQLServerDAL”么
    ConfigurationManager.AppSettings["WebDAL"]; 
    <appSettings> <add key="WebDAL" value="路径+FlyingCanada1.SQLServerDAL"/> </appSettings> 
      

  2.   

    找不到程序集FlyingCanada1.SQLServerDAL。
    估计你的程序集名字是SQLServerDAL。把它改成FlyingCanada1.SQLServerDAL试试。