日期:2014-05-17  浏览次数:20421 次

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&nbs