1 //这是配子文件 2 <configSections> 3 <section name="unity" type="Microsoft.Practices.Unity.Configuration.UnityConfigurationSection, Microsoft.Practices.Unity.Configuration"/> 4 </configSections> 5 <unity> 6 7 <alias alias="IUserInfoBLL" type="IMyOfficeBLL.IUserInfoBLL,IMyOfficeBLL" /> 8 9 <alias alias="IUserInfoDAL" type="IMyOfficeDAL.IUserInfoDAL,IMyOfficeDAL" /> 10 11 <alias alias="UserInfoDAL" type="MyOffice.UserInfoDAL,MyOfficeDAL"/> 12 13 <alias alias="UserInfoBLL" type="MyOfficeBLL.UserInfoBLL,MyOfficeBLL"/> 14 15 <alias alias="UserInfo" type="WebUI.Controllers.UserInfoController,WebUI" /> 16 17 <alias alias="MyOfficeModels" type="MyOfficeModels" /> 18 <container name="default"> 19 <register type="IUserInfoDAL" mapTo="UserInfoDAL"/> 20 <register type="IUserInfoBLL" mapTo="UserInfoBLL" > 21 <property name="UserInfo"> 22 <dependency/> 23 </property> 24 </register> 25 <register type="UserInfo" mapTo="UserInfo"> 26 <property name="bll"> 27 <dependency/> 28 </property> 29 </register> 30 </container> 31 </unity> 32 33 //接口类 34 namespace IMyOfficeDAL 35 { 36 public interface IUserInfoDAL 37 { 38 int VailUser(string name,string pass); 39 } 40 } 41 //实现上面接口类 42 using MyOfficeModels; 43 using IMyOfficeDAL; 44 45 namespace MyOfficeDAL 46 { 47 public class UserInfoDAL:IUserInfoDAL 48 { 49 50 #region IUserInfo 成员 51 52 MyOfficeEntities content = new MyOfficeEntities(); 53 54 //查询数据库是否存在 55 public int VailUser(string name, string pass) 56 { 57 int result = content.UserInfoes.Count(u => u.UserId == name && u.PassWord==pass); 58 return result; 59 } 60 61 #endregion 62 } 63 } 64 65 public static void RegisterType() 66 { 67 UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity"); 68 uc.LoadConfiguration(section, "default"); 69 }
请仔细看11行(编号11),个人目测有问题。
<alias alias="UserInfoDAL" type="MyOffice.UserInfoDAL,MyOfficeDAL"/>
@幻天芒: 谢谢 到头还是程序集的问题。
@土匪吃黄瓜: 额,这也能遇到...