首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

未经处理的错误: System.IO.FileNotFoundException: 未能加载文件或程序集“accessDA

2013-12-02 
未经处理的异常:System.IO.FileNotFoundException: 未能加载文件或程序集“accessDA1.调试时出现图片:上面

未经处理的异常: System.IO.FileNotFoundException: 未能加载文件或程序集“accessDA
1.调试时出现图片:上面写着:“System.IO.FileNotFoundException”类型的未经处理的异常出现在 mscorlib.dll 中。
其他信息: 未能加载文件或程序集“accessDAL”或它的某一个依赖项。系统找不到指定的文件
2.工厂(DALFactor)的代码:using System;
using System.Reflection;

namespace DALFactory
{
    public sealed class DataAccess
    {
        private static string path = "accessDAL";
        public static object CreateObject(string className)
        {
            string classname = path + "." + className;
            return Assembly.Load(path).CreateInstance(classname);
        }
    }
3.实现类accessDAL的代码:using System;
using System.Collections.Generic;
using System.Data.OleDb;

namespace accessDAL
{
    public class ABook:IDAL.IBook
    {
        private static string conn = "Provider=Microsoft.Jet.OleDb.4.0;Data Source='I:/软件工程/book.mdb'";
        public Model.Book getBook(string b_name)
        {

            string sqlstring = "select * from book where b_name like " + "'%" + b_name + "%'";
            OleDbConnection ole = new OleDbConnection(conn);
            OleDbCommand dbc = new OleDbCommand(sqlstring, ole);
            ole.Open();
            OleDbDataReader p = dbc.ExecuteReader();
            if (p.Read() == true)
            
            return new Model.Book(p.GetString(0), p.GetFloat(1), p.GetInt32(2), p.GetString(3));
            else
                return null;
        }
    }
}
4.
本人经过各种努力,还是解决不了该问题。。。实在没辙了,希望各位大神帮帮小弟
[解决办法]
你需要加载的dll相关文件在不在运行目录下?

给几个链接看看吧:
http://blog.csdn.net/guxiaoshi/article/details/5009604
http://space.itpub.net/12639172/viewspace-442007
http://www.cnblogs.com/danielWise/archive/2011/09/07/2170042.html

热点排行