This is the development list. For support request please use the nhusers group http://nhforge.org/groups/
2010/1/18 niberhate <[email protected]> > I am playing with the HelloNHibernate example of NHibernate In > Action. The source code can be downloaded from > http://www.manning.com/kuate/NHibernateInAction.Source.zip > > You will find an example solution called "1. Simple Example - Helllo > NHibernate" in that zip package. > > Because the objective of that example is to have the minimum working > solution of NHibernate, it has public fields instead of private. The > fields are Id, Name and Manager (I use PascalStyle for naming > convention, so I capitalized the initial characters of these fields.) > > So, I changed the public fields into public auto properties, and then > the following method throws and exception at c.AddAssembly > (Assembly.GetCallingAssembly()); > > static ISession OpenSession() > { > if (factory == null) > { > Configuration c = new Configuration(); > c.AddAssembly(Assembly.GetCallingAssembly()); > factory = c.BuildSessionFactory(); > } > return factory.OpenSession(); > } > > The exception says: > > {"Could not compile the mapping document: > HelloNHibernate.HelloNHibernate.Employee.hbm.xml"} > > And the inner exception says: > > {"Problem trying to set property type by reflection"} > > In other words, everything else being the same, the following works: > > namespace HelloNHibernate > { > class Employee > { > public int Id; > public string Name; > public Employee Manager; > > public string SayHello() > { > return string.Format( > "'Hello World!', said {0}.", Name); > } > } > } > > > Whereas the following fails: > > namespace HelloNHibernate > { > class Employee > { > public int Id { get; private set; } > public string Name { get; set; } > public Employee Manager { get; set; } > > public string SayHello() > { > return string.Format( > "'Hello World!', said {0}.", Name); > } > } > } > > What is the caveat? Does NHibernate have any special configuration > requirement for auto properties to work? Any idea? Thanks. > -- Fabio Maulo
