The type initializer for 'NHibernate.Cfg.Configuration' threw an exception.

1,356 views
Skip to first unread message

AzamSharp

unread,
Jun 21, 2009, 12:03:13 AM6/21/09
to Fluent NHibernate
For some reason I am getting the following error:

"The type initializer for 'NHibernate.Cfg.Configuration' threw an
exception"

Here is the FluentNHibernte code to setup the assemblies:

public static ISessionFactory CreateSessionFactory()
{
return
Fluently.Configure().Database(
MsSqlConfiguration.MsSql2000.ConnectionString(
c => c.FromConnectionStringWithKey
("HighOnCodingConnectionString")))
.Mappings(m =>
m.FluentMappings.AddFromAssemblyOf<Category>())
.BuildSessionFactory();
}


David Lawton

unread,
Jun 21, 2009, 5:42:16 AM6/21/09
to fluent-n...@googlegroups.com
What nhibernate version r u using?

Sent from my iPhone

AzamSharp

unread,
Jun 21, 2009, 11:14:25 AM6/21/09
to Fluent NHibernate
Hi,

I downloaded from Subversion http://fluent-nhibernate.googlecode.com/svn/trunk/

It is version 2.0.1.4000

Thanks,
Azam

On Jun 21, 4:42 am, David Lawton <da...@davetheninja.net> wrote:
> What nhibernate version r u using?
>
> Sent from my iPhone
>

AzamSharp

unread,
Jun 21, 2009, 1:34:33 PM6/21/09
to Fluent NHibernate
Any ideas!

On Jun 21, 4:42 am, David Lawton <da...@davetheninja.net> wrote:
> What nhibernate version r u using?
>
> Sent from my iPhone
>

Dylan Beattie

unread,
Jun 21, 2009, 1:39:23 PM6/21/09
to fluent-n...@googlegroups.com
If you're running against the trunk from Subversion, you probably need an additional line in your configuration to set up the ProxyFactoryFactory:
 
return Fluently.Configure()
    .Database(MsSqlConfiguration.MsSql2005.ConnectionString(s => s.FromConnectionStringWithKey("my_connection_string"))
    .ProxyFactoryFactory("NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle"))
    .Mappings(m =>
     m.FluentMappings.AddFromAssemblyOf<Program>())
    .ExposeConfiguration(BuildSchema)
    .BuildSessionFactory();
 
Check the InnerException property of your type initializer exception - that should give you some more detail about what's going wrong.
 
-D-


 
2009/6/21 AzamSharp <azam...@gmail.com>

Kurt Johnson

unread,
Jun 21, 2009, 3:58:14 PM6/21/09
to fluent-n...@googlegroups.com
Would this still apply if you've included the ProxyFactory in the nhibernate.cfg.xml?

Reason I ask, is that I have seen the error and still have a proxy factory in my cfg.

Tuna Toksoz

unread,
Jun 21, 2009, 3:59:57 PM6/21/09
to fluent-n...@googlegroups.com
Was there any inner exception?

Tuna Toksöz
Eternal sunshine of the open source mind.

http://devlicio.us/blogs/tuna_toksoz
http://tunatoksoz.com
http://twitter.com/tehlike
Reply all
Reply to author
Forward
0 new messages