如何运行Castle Active REcord示例

时间:2011-04-03 03:53:55

标签: c# castle-activerecord

我无法在VS2010 + mssql2008下的城堡网站上运行正常示例(我在ms win xp下尝试 - mssql2005 + ms c#2010 express)

...

//我们正在使用XmlConfigurationSource:  XmlConfigurationSource source = new XmlConfigurationSource(“appconfig.xml”);

ActiveRecordStarter.Initialize(source,typeof(Blog),typeof(Post),typeof(User)); ...

在app.cs模块的Initialize中有一个异常: {“'NHibernate.LoggerProvider'的类型初始值设定项引发了异常。”}

内部异常:

{“无法识别的配置部分配置。(C:\ Documents and Settings \ Administrator \ My Documents \ Visual Studio 2005 \ Projects \ bin \ BlogSample.vshost.exe.Config第3行)”}

有什么不对? xml config:

<?xml version="1.0" encoding="utf-8" ?>

<configuration>

  <configSections>
    <section name="activerecord"
                 type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler, Castle.ActiveRecord" />
  </configSections>

  <activerecord isWeb="false" pluralizeTableNames="true">

    <config>
      <add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
      <add key="hibernate.dialect"                 value="NHibernate.Dialect.MsSql2000Dialect" />
      <add key="hibernate.connection.provider"     value="NHibernate.Connection.DriverConnectionProvider" />
      <add key="hibernate.connection.connection_string"  value="Data Source=|DataDirectory|\Gecko1#1.sdf;Password=ghbdtn185" />
    </config>

  </activerecord>

</configuration>

为此我试试

 < ?xml version="1.0" encoding="utf-8" ?>
< activerecord isWeb="false" pluralizeTableNames="true">
  < config>
    < add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
    < add key="hibernate.dialect"                 value="NHibernate.Dialect.MsSql2005Dialect" />
    < add key="hibernate.connection.provider"     value="NHibernate.Connection.DriverConnectionProvider" />
    < add key="hibernate.connection.connection_string"  value="Data  Source=|DataDirectory|\Gecko1#1.sdf;Password=ghbdtn185" />
  < /config>
< /activerecord>

但我明白了:

{“配置系统无法初始化”}

1 个答案:

答案 0 :(得分:0)

该示例代码非常旧(最初是VS2003)。我建议使用these projects中的一个作为参考,尽管该列表现在也有些陈旧(但不像示例代码那么陈旧)