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

MVC4--工厂模式异常,帮忙解决一下

2013-04-20 
MVC4--工厂模式错误,帮忙解决一下。项目结构:错误截图:web.config中已经设置appSettingsadd keyDALPat

MVC4--工厂模式错误,帮忙解决一下。
项目结构:
MVC4--工厂模式异常,帮忙解决一下
错误截图:
MVC4--工厂模式异常,帮忙解决一下


web.config中已经设置
    <appSettings>
      <add key="DALPath" value="Zjgcxx.EFDAL" />
      <add key="HZ" value="DAL" />
  </appSettings>

各项目之间该引用的都已引用,部份代码如下:
DALFacotry.cs


using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;

namespace Zjgcxx.DALFactory
{
    public class DALFactory
    {
        public static readonly string DALPath = System.Configuration.ConfigurationSettings.AppSettings["DALPath"];
        public static readonly string DALHZ = System.Configuration.ConfigurationSettings.AppSettings["HZ"];

        
        /// <summary>
        /// 创建实例
        /// </summary>
        /// <param name="assemblyPath"></param>
        /// <param name="objType"></param>
        /// <returns></returns>
        public static object CreateDAL(string assemblyPath, string objType)
        {
            var cacheDAL = DALCache.GetDAL(objType);
            if (cacheDAL == null)
            {
                cacheDAL = Assembly.Load(assemblyPath).CreateInstance(objType); //此句提示出错
                DALCache.SaveDAL(objType, cacheDAL);
            }
            return cacheDAL;
        }

    }
}

Web_userDALFactory.cs

using System;
using Zjgcxx.IDAL;

namespace Zjgcxx.DALFactory
{
    public class Web_userDALFactory : DALFactory
    {
        /// <summary>
        /// 获取 Web_user 的具体实例
        /// </summary>
        /// <returns></returns>
        public static IWeb_userDAL Create()
        {
            //从配置中获取 sql、oracle 还是 EF 的实例
            return CreateDAL(DALPath, string.Format("{0}.Web_user{1}", DALPath, DALHZ)) as IWeb_userDAL;


        }
    }
}




Web_user是用户表名称,相对应的EFDAL类是
using ...
namespace Zjgcxx.EFDAL
{
    public class Web_userDAL : IWeb_userDAL
    {
        ...
    }
}


各位前辈帮忙看看问题在哪,谢谢。

[解决办法]
添加了对Zjgcxx.EFDAL的dll引用了没有?
[解决办法]
错误的原因楼主不是知道啦吗,还找不到哪里错了?
[解决办法]
看下物理文件在bin下面吗?重新生成看下。
还有就是你那个dll有没引用其他的dll,看下是否有问题
[解决办法]
也许它给你解析成  Zjgcxx.EFDAL  ,我说的意思是  zjgcxxx 下面的 EFDAL ,而当然的 ,你的 zjgcxx 下面没有  EFDAL 。所以就报错了?

热点排行