views:

21

answers:

1

Hi there, I am working with Spring.net 1.3 and nHibernate for .net 1.3. While fetching the application context using XML ( _appContext = new XmlApplicationContext("abc.xml")) I am getting the exception as "Error creating object with name 'NHibernateSessionFactory' defined in abc.xml" Initialization of object failed : The following types may not be used as proxies"

I have declared all the properties of class as public virtual.still why am i getting this exception

Thanks in advance

A: 

You must have missed marking a property or method virtual. The exception (or an InnerException, I'm not familiar with Spring) message should tell you exactly which type is the problem. For example, I just reproduced this:

{"The following types may not be used as proxies:\nModel.Project: method get_ProjectId should be 'public/protected virtual' or 'protected internal virtual'"}
Jamie Ide
Another aspect you need to consider is to set your Compile Action to Embedded Resource for your mapping files, in addition that they must have both HBM.XML extensions. I'm not sure on the fly like this, but I believe this could also cause the problem.
Will Marcouiller