views:

977

answers:

2

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();
        //
    }
+1  A: 

OK.. got it working.

The version of a NHibernate that I have requires to have "hibernate" in the key attributes.

example

Instead of this:

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

do like this:

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

For newer version of NHibernate the opposite works.

Nick
A: 

Hi, does your Visual Studio prompt you when you type : value="NHibernate.Driver.SqlClientDriber"....

Prashanth