3

Hi I am having getting an exception when trying to initialize ActiveRecord and I cannot figure out what I am missing. I am trying to convince the company I work for to use Castle ActiveRecord and it won't look good if I can't demonstrate how it works. I have work on projects before with Castle ActiveRecord and I had never experience this problem before.

Thanks for your help

The exception that I get is

Stack Trace:

at Castle.ActiveRecord.ActiveRecordStarter.AddXmlString(Configuration config, String xml, ActiveRecordModel model) at Castle.ActiveRecord.ActiveRecordStarter.AddXmlToNHibernateCfg(ISessionFactoryHolder holder, ActiveRecordModelCollection models) at Castle.ActiveRecord.ActiveRecordStarter.RegisterTypes(ISessionFactoryHolder holder, IConfigurationSource source, IEnumerable`1 types, Boolean ignoreProblematicTypes) at Castle.ActiveRecord.ActiveRecordStarter.Initialize(IConfigurationSource source, Type[] types) at ConsoleApplication1.Program.Main(String[] args) in C:\Projects\CastleDemo\ConsoleApplication1\Program.cs:line 20 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()

Inner Exception:

{"Could not compile the mapping document: (string)"}

Below is my configuration file:

<add
    key="connection.driver_class"
    value="NHibernate.Driver.SqlClientDriver" />
<add
    key="dialect"
    value="NHibernate.Dialect.MsSql2000Dialect" />
<add
    key="connection.provider"
    value="NHibernate.Connection.DriverConnectionProvider" />
<add
    key="connection.connection_string"
    value="Data Source=SPIROS\SQLX;Initial Catalog=CastleDemo;Integrated Security=SSPI" />
<add
    key="proxyfactory.factory_class"
    value="NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle" />

and this is the main method that runs the initialization:

    static void Main(string[] args)
    {
        //Configure ActiveRecord source
        XmlConfigurationSource source = new XmlConfigurationSource("../../config.xml");
        //

        //Initialazi ActiveRecord
        ActiveRecordStarter.Initialize( source, typeof(Product));
        //

        //Create Schema
        ActiveRecordStarter.CreateSchema();
        //
    }
4

2 回答 2

5

好的..让它工作。

我拥有的 NHibernate 版本需要在关键属性中具有“休眠”。

例子

而不是这个:

<add 
    key="connection.driver_class"
    value="NHibernate.Driver.SqlClientDriver"/>

这样做:

<add key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />

对于较新版本的 NHibernate,则相反。

于 2009-10-09T19:59:35.387 回答
0

当您键入以下内容时,您的 Visual Studio 是否会提示您: value="NHibernate.Driver.SqlClientDriber"....

于 2010-03-29T03:04:43.393 回答