Put a try-catch around the call to
Initialize, or look in the NHibernate logs [1], and you’ll likely see
that something happened when AR tried building the map, or loading the object
to which the map refers, which causes the call to initialize to fail.
Another thing you might want to try is
using the ActiveRecord Facility with the Windsor
container and MonoRail [2].
Or, you could wait for some of the other
folks to come online and answer you… they seem to have a preternatural
ability to identify problems with almost no input.
- Richard
[1] http://www.castleproject.org/index.php/ActiveRecord:Troubleshooting
[2] http://www.castleproject.org/index.php/Facility:ActiveRecord
From:
[EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Jeremy Arnold
Sent: Wednesday, June 21, 2006
1:45 PM
To:
[email protected]
Subject: Re: [Castle-users] did
you forget aboutActiveRecordStart.Initialize error......
In reply to my own, I
amended my code (pasted at the bottom) still to no avail. :(
public void Application_OnStart()
{
container = new
WebContainer();
InPlaceConfigurationSource
source = new InPlaceConfigurationSource();
Hashtable
properties = new Hashtable();
properties.Add("hibernate.connection.driver_class",
"NHibernate.Driver.MySqlDataDriver");
properties.Add(" hibernate.dialect",
"NHibernate.Dialect.MySQLDialect");
properties.Add("hibernate.connection.provider",
"NHibernate.Connection.DriverConnectionProvider");
properties.Add ("hibernate.connection.connection_string",
"Database=monorailtest;Data Source=localhost;User
Id=*****;Password=******");
source.Add(typeof(ActiveRecordBase), properties);
ActiveRecordStarter.Initialize(source, typeof(User), typeof(AccessLevel));
}
On 6/21/06, Jeremy
Arnold < [EMAIL PROTECTED]>
wrote:
I've been struggling to get back in the hang of monoRail since the last
time i used it 8-9 months ago with asp.net
1.1..
I've created a vs.net 2005 project
with a web site and a class library (so i can debug with F5 ;) )
The class library was created from the Visual Studio MonoRail Add-In project
type whatevah whatevah....
All of my controls are working like a champ but i am getting the all so
classical :
An ActiveRecord class (
MyMonoRailBack.Models.User) was used but the framework seems not properly
initialized. Did you forget about ActiveRecordStarter.Initialize() ?
I have tested the same active record settings in another project and they
worked, as did the models i am working with...
I am initializing it in GlobalApplication.cs here:
public void Application_OnStart()
{
container = new WebContainer();
IConfigurationSource source =
System.Configuration.ConfigurationSettings.GetConfig("activerecord")
as IConfigurationSource;
ActiveRecordStarter.Initialize(source, typeof(User), typeof(AccessLevel));
}
and my web.config file contains the following:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="monoRail"
type="Castle.MonoRail.Framework.Configuration.MonoRailSectionHandler,
Castle.MonoRail.Framework" />
<section
name="castle"
type="Castle.Windsor.Configuration.AppDomain.CastleSectionHandler,
Castle.Windsor" />
<section
name="activerecord"
type="Castle.ActiveRecord.Framework.Config.ActiveRecordSectionHandler,
Castle.ActiveRecord" />
</configSections>
<monoRail>
<controllers>
<assembly>MyMonoRailBack</assembly>
</controllers>
<viewEngine
viewPathRoot="views"
customEngine="Castle.MonoRail.Framework.Views.NVelocity.NVelocityViewEngine,
Castle.MonoRail.Framework.Views.NVelocity"/>
</monoRail>
<castle>
<include uri="file://facilities.config" />
<include uri=" file://controllers.config" />
</castle>
<activerecord>
<config>
<add
key="hibernate.connection.driver_class" value="
NHibernate.Driver.MySqlDataDriver" />
<add
key="hibernate.dialect"
value="NHibernate.Dialect.MySQLDialect" />
<add key="hibernate.connection.provider "
value="NHibernate.Connection.DriverConnectionProvider" />
<add
key="hibernate.connection.connection_string"
value="Database=monorailtest;Data Source=localhost;User
Id=pfftt;Password=notforyou" />
</config>
</activerecord>
<system.web>
<!-- IIS will bitch if you don't turn custom errors mode
off! -->
<customErrors mode="Off"/>
<!-- Required for "F5" support in VS 2005, but
we won't be using dynamic compilation anyway -->
<compilation debug="true"/>
<httpHandlers>
<add verb="*"
path="*.aspx" type="
Castle.MonoRail.Framework.MonoRailHttpHandlerFactory,
Castle.MonoRail.Framework" />
</httpHandlers>
</system.web>
</configuration>
At this point I've meesed with so much trying to fix I don't know where to
go! Can anyone point me in the right direction as to what the problem is?
Thanks,