首页新闻找找看学习计划

activeRecord 配置多数据,代码出错! 帮忙解决啊!!

0
悬赏园豆:100 [已关闭问题] 关闭于 2010-10-29 16:44
Web.config 配置
1 <?xml version="1.0" encoding="utf-8"?>
2  <configuration>
3 <configSections>
4 <!--sql的配置节-->
5 <section name="activerecord" type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord" />
6 </configSections>
7 <!--sql的active配置-->
8  <activerecord isWeb="true">
9 <config>
10 <add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
11 <add key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
12 <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
13 <add key="hibernate.connection.connection_string" value="server=.;User ID=sa;Password=sa;database=DataTranst;Connection Reset=FALSE" />
14 </config>
15 <config type="DateOut.Access.Access_Base,DataOut.Access" >
16 <add key="hibernate.connection.driver_class" value="NHibernate.Driver.OleDbDriver, castle.format" />
17 <add key="hibernate.dialect" value="NHibernate.JetDriver.JetDialect, castle.format" />
18 <add key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
19 <add key="hibernate.connection.connection_string" value="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=2;Persist Security Info=True" />
20 </config>
21 </activerecord>
22
23 <appSettings>
24 <!--sql程序集位置-->
25 <add key="Sql_AssemblyName" value="DateOut.Model"/>
26 <!--access程序集位置-->
27 <add key="Access_AssemblyName" value="DateOut.Access"/>
28 </appSettings>
29  
Access的配置
1 namespace DateOut.Access
2 {
3 [ActiveRecord()]
4 public abstract class Access_Base<T> : ActiveRecordBase<T>
5 {
6
7 }
8
9 [Serializable]
10 [ActiveRecord("UserInfo")]
11 public class UserInfo_Access:Access_Base<UserInfo_Access>
12 {
13 private int _id;
14 /// <summary>
15 /// 主键
16 /// </summary>
17   [PrimaryKey(PrimaryKeyType.Native)]
18 public int Id
19 {
20 get { return _id; }
21 set { _id = value; }
22 }
23
24 private string _name;
25 /// <summary>
26 /// 姓名
27 /// </summary>
28 [Property]
29 public string Name
30 {
31 get { return _name; }
32 set { _name = value; }
33 }
34
35 private int _age;
36
37 /// <summary>
38 /// 年龄
39 /// </summary>
40 [Property]
41 public int Age
42 {
43 get { return _age; }
44 set { _age = value; }
45 }
46
47 }
sqlserver配置
1 namespace DateOut.Model
2 {
3 [Serializable]
4 [ActiveRecord("UserInfo")]
5 public class UserInfo:ActiveRecordBase<UserInfo>
6 {
7 private int _id;
8 /// <summary>
9 /// 主键
10 /// </summary>
11 [PrimaryKey(PrimaryKeyType.Native)]
12 public int Id
13 {
14 get {return _id;}
15 set { _id=value;}
16 }
17
18
19 private string _name;
20 /// <summary>
21 /// 姓名
22 /// </summary>
23 [Property]
24 public string Name
25 {
26 get { return _name; }
27 set { _name = value; }
28 }
29
30 private int _age;
31
32 /// <summary>
33 /// 年龄
34 /// </summary>
35 [Property]
36 public int Age
37 {
38 get { return _age; }
39 set { _age = value; }
40 }
41
42 }
active初始化
1 public class Global : System.Web.HttpApplication
2 {
3
4
5
6 private Assembly _assemblyObj_sql = Assembly.Load(ConfigurationManager.AppSettings["Sql_AssemblyName"].ToString());
7 private Assembly _assemblyObj_access = Assembly.Load(ConfigurationManager.AppSettings["Access_AssemblyName"].ToString());
8
9
10 private IConfigurationSource _configSource_sql = (ConfigurationManager.GetSection("activerecord") as IConfigurationSource);
11
12 protected void Application_Start(object sender, EventArgs e)
13 {
14 ArrayList sql_list = new ArrayList();
15 sql_list.AddRange(this._assemblyObj_sql.GetTypes());
16 sql_list.AddRange(this._assemblyObj_access.GetTypes());
17 ActiveRecordStarter.Initialize(this._configSource_sql, (Type[])sql_list.ToArray(typeof(Type)));
18 }
19

 

测试
1 DateOut.Model.UserInfo userInfo = DateOut.Model.UserInfo.FindOne(new EqExpression("Name", "小张"));
2 DateOut.Access.UserInfo_Access userInfo_access = new DateOut.Access.UserInfo_Access();
3 userInfo_access.Age = userInfo.Age;
4 userInfo_access.Name = userInfo.Name;
5 userInfo_access.Id = userInfo.Id;
6 userInfo_access.Create();
7

 

 

想用activeRecord配置两个数据库,一个sqlserver,一个access.

代码在active初始化 第10行的时候,报

Could not obtain type from name 'DateOut.Access.Access_Base,DataOut.Access'

说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.Configuration.ConfigurationErrorsException: Could not obtain type from name 'DateOut.Access.Access_Base,DataOut.Access'

源错误:

行 24:     行 25: 行 26:         private IConfigurationSource _configSource_sql = (ConfigurationManager.GetSection("activerecord") as IConfigurationSource);行 27:       

 

我不知道是怎么回事!  是不是activeRecord不支持多数据?? 还是配置问题?  帮帮忙啊

hnnnhhl的主页 hnnnhhl | 初学一级 | 园豆:200
提问于:2010-10-26 15:32
< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册