艹,研究了快一天了,其实也没一天,就半天而已。出现了一个问题,没有将对象引用到示例的这个错误·找遍了所有的引用·。也没有发现问题!代码如下 UserInfo _userinfo = UserInfoBll.Get_UserInfoModel(userid); 调用然后继续:
using ClothingModel; //实体层
using IDataAccessLayerBase;//接口
using DataAccessLayerFactory;//工厂
namespace PMS.ClothingBll  //逻辑层        public static UserInfo Get_UserInfoModel(string UserId)
        {
            return dal.Get_UserInfoModel(UserId);
        }
如果直接点击转到定义还是没有问题的,可以跳转---------------------------------------------
下面是工厂
using System;
using System.Web;namespace DataAccessLayerFactory
{
    public class DataCache
    {
        public DataCache()
        {
            //
            // TODO: Add constructor logic here
            //
        }        /// <summary>
        /// 
        /// </summary>
        /// <param name="CacheKey"></param>
        /// <returns></returns>
        public static object GetCache(string CacheKey)
        {            System.Web.Caching.Cache objCache = HttpRuntime.Cache;
            return objCache[CacheKey];        }        /// <summary>
        /// 
        /// </summary>
        /// <param name="CacheKey"></param>
        /// <param name="objObject"></param>
        public static void SetCache(string CacheKey, object objObject)
        {
            System.Web.Caching.Cache objCache = HttpRuntime.Cache;
            objCache.Insert(CacheKey, objObject);
        }
    }
}
-----------------------------------------------------
using ClothingModel;
using DBUtlity;
using IDataAccessLayerBase;
namespace PMS.ClothingDal 
 public partial class UserInfoDal : IUserInfoDALSub //继承
{  ////////下面是实现代码·····
}
-----------------------------
using System;
using System.Reflection;
using IDataAccessLayerBase;
namespace DataAccessLayerFactory
{
    public class DataAccessFactory
    {
        private static readonly string path = System.Configuration.ConfigurationManager.AppSettings["clothging"];  //------------------- 我在配置文件里面key里面填写的是这个,values写的是dal程序集的引用        private static object CreateObject(string path, string CacheKey)
        {
            object objType = DataCache.GetCache(CacheKey);
            if (objType == null)
            {
                try
                {
                    objType = Assembly.Load(path).CreateInstance(CacheKey);
                    DataCache.SetCache(CacheKey, objType);
                }
                catch { }            }
            return objType;
        }
        /// <summary>
        /// 通过反射机制,实例化UserInfo接口对象。
        /// </summary>
        ///<returns>Employee接口对象</returns>
        public static IUserInfoDALSub Create_UserInfo()
        {
            string CacheKey = path + ".PMS.ClothingDal";
            object objType = CreateObject(path, CacheKey);
            return (IUserInfoDALSub)objType;
        }
最后跳到逻辑层的 return dal.Get_UserInfoModel(UserId);没有引用到示例,但是我添加了引用。也没发现任何问题有没有告诉一下原因?

解决方案 »

  1.   

    dal.Get_UserInfoModel(UserId)关键的没贴出来另外,你看异常信息啊。
    dal
    UserId
    看哪个是null
      

  2.   

    dal.Get_UserInfoModel方法呢?
    你的工厂写的是没问题的。
      

  3.   


    dal这边添加了阴影。  userid也不是空的··什么关键信息?未能加载文件或程序集“PMS.ClothingDal”或它的某一个依赖项。系统找不到指定的文件
    就这个问题··但是我明明添加了引用···
      

  4.   

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;namespace ClothingModel
    {
        /// <summary>
        /// UserInfo数据实体
        /// </summary>
        [Serializable]
        public class UserInfo
        {
            private int _id;
            private string _userid = String.Empty;
            private string _userpwd = String.Empty;
            private int _status;
            private DateTime _createtime;
            private DateTime _deletetime;
            private string _username = String.Empty;
            private DateTime _updateTime;
            /// <summary>
            /// 
            /// </summary>
            public UserInfo() { }        public UserInfo
          (
            int id,
            string userid,
            string userpwd,
            int status,
            DateTime createtime,
            DateTime deletetime,
            string username,
            DateTime updatetime    )
            {
                _id = id;
                _userid = userid;
                _userpwd = userpwd;
                _status = status;
                _createtime = createtime;
                _deletetime = deletetime;
                _updateTime = updatetime;
            }
            /*
            public class UserInfo
            {
             public UserInfo() { }            #region Model
                private int _id;
                private string _userid;
                private string _userpwd;
                private int _status;
                private DateTime _createtime;
                private DateTime _deletetime;
                private string _username;
                private DateTime _updateTime;
              */
            /// <summary>
            /// 
            /// </summary>
            public int ID
            {
                set { _id = value; }
                get { return _id; }
            }        public string UserName
            {
                set { _username = value; }
                get { return _username; }
            }
            /// <summary>
            /// 
            /// </summary>
            public string UserId
            {
                set { _userid = value; }
                get { return _userid; }
            }
            /// <summary>
            /// 
            /// </summary>
            public string UserPwd
            {
                set { _userpwd = value; }
                get { return _userpwd; }
            }
            /// <summary>
            /// 
            /// </summary>
            public int Status
            {
                set { _status = value; }
                get { return _status; }
            }
            /// <summary>
            /// 
            /// </summary>
            public DateTime CreateTime
            {
                set { _createtime = value; }
                get { return _createtime; }
            }
            /// <summary>
            /// 
            /// </summary>
            public DateTime DeleteTime
            {
                set { _deletetime = value; }
                get { return _deletetime; }
            }
            public DateTime UpdateTime
            {
                set { _updateTime = value; }
                get { return _updateTime; }
            }    }
    }
    上面是model
      

  5.   

      UserInfo Get_UserInfoModel(string UserId); 这个就是的= =
      

  6.   

    检查web.config里是否修改了<add key="clothging" value="Maticsoft.SQLServerDAL" />。
      

  7.   

       <add key="clothging" value="PMS.ClothingDal" />  数据层的程序集就叫这个名字。最后就是可以跳到接口这边来,然后就是反射不到dal里面去·。···
      

  8.   

    反射调用的dll有吗?
    还有,文件名加上.dll试试。
      

  9.   

    还是没有看到关键代码,如果已确定dal!=null
    就右键转到dal.Get_UserInfoModel(UserId)的定义看一下这个里面
      

  10.   


            public static UserInfo Get_UserInfoModel(string UserId)
            {
                return dal.Get_UserInfoModel(UserId);
            }
    //上面直接跳到下面来了。没有问题的·
            UserInfo Get_UserInfoModel(string UserId);
      

  11.   


    叼,刚才判断了一下,已经确定dal=null,这是神马原因?