艹,研究了快一天了,其实也没一天,就半天而已。出现了一个问题,没有将对象引用到示例的这个错误·找遍了所有的引用·。也没有发现问题!代码如下 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);没有引用到示例,但是我添加了引用。也没发现任何问题有没有告诉一下原因?
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);没有引用到示例,但是我添加了引用。也没发现任何问题有没有告诉一下原因?
解决方案 »
- 哪位朋友熟悉IOCOMP中的PLOTX趋势图控件,有问题想请教
- 我有个C#编的小游戏代码,谁可以把它实现,是windows应用程序
- 放弃程序员了~~不玩了!散分···
- C#
- 请高手过来看看,关于xml的解析
- 如何让dataGrid中某列可编辑,而其他列不可编辑?(WinForm)
- 关于window2000 Server Advance里自定义打印纸的问题
- C#问题:System.Array.LastIndexOf(myArray,a,b,c)方法好像有BUG啊?大伙快来看看。
- 怎么让一段代码在指定的时间自动执行?
- Thread.spinWait()有什么作用?MSDN里面没讲清楚!
- 上网管理软件的思路以及所需技术
- 怎么继承泛型接口
dal
UserId
看哪个是null
你的工厂写的是没问题的。
dal这边添加了阴影。 userid也不是空的··什么关键信息?未能加载文件或程序集“PMS.ClothingDal”或它的某一个依赖项。系统找不到指定的文件
就这个问题··但是我明明添加了引用···
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
还有,文件名加上.dll试试。
就右键转到dal.Get_UserInfoModel(UserId)的定义看一下这个里面
public static UserInfo Get_UserInfoModel(string UserId)
{
return dal.Get_UserInfoModel(UserId);
}
//上面直接跳到下面来了。没有问题的·
UserInfo Get_UserInfoModel(string UserId);
叼,刚才判断了一下,已经确定dal=null,这是神马原因?