Hello my friends,
I'm doing a test on NHibernate with PostgreSQL + PostGIS db.
All reference is added, but there is an error: Dialec couln't load. The dialec is NHibernate.Spatial.Dialect.PostGisDialect as information at this article. This dialec is in the external dll: NHibernate.Spatial.PostGis.dll. Here is introduction information:
How can I configure to make this external dialec working with NHibernate?
My App.config is below:
--------------------------------------------------------------------
<?xml version="1.0"?> <configuration> <configSections> <section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate"/> </configSections> <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2"> <session-factory> <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property> <property name="dialect">NHibernate.Spatial.Dialect.PostGisDialect,NHibernate.Spatial.PostGis</property> <property name="connection.driver_class">NHibernate.Driver.NpgsqlDriver</property> <property name="connection.connection_string">Server=127.0.0.1;Port=5432;Database=demogis;User Id=postgres;Password=mypassword;Preload Reader = true;</property> <!-- NHibernate 2.1 --> <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property> <mapping assembly="DemoGISData"/> </session-factory> </hibernate-configuration> <startup><supportedRuntime version="v2.0.50727"/></startup></configuration>
For a day to debug, I found that: All external types from NHibernate couldn't be gotten while all reference DLLs are existed at application directory.So, I merged NHibernate.Spatial and NHibernate.Spatial.PostGis to NHibernate and some exceptions are fixed.
But the ReflectHelper.TypeFromAssembly(AssemblyQualifiedTypeName name, bool throwOnError) throws an exception for NHibernate.ByteCode.LinFu.ProxyFactoryFactory:Could not load file or assembly 'NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4"} System.Exception {System.IO.FileLoadException}Assembly.Load(name.Assembly).GetTypes() throws an exception as below:Assembly.Load(name.Assembly).GetTypes()' threw an exception of type 'System.Reflection.ReflectionTypeLoadException' System.Type[] {System.Reflection.ReflectionTypeLoadException}
Plese help me. NHibernate may be so complex.
Hello,
It looks like the PostGisDialect was compiled against a different version of the nHibernate assembly. If you can get the source to this I would reference the NHibernate assembly from your project and rebuild. I'd post a message on the forum / place that you got this dialect and mention the version of the NHibernate assemblies you are using (latest).
Please correct me if my assumption is incorrect.
Thanks
-Blake Niemyjski
Blake Niemyjski CodeSmith Tools, LLC. Software Development Engineer Blog: http://windowscoding.com/blogs/blake/ .NetTiers team | Visit http://www.nettiers.com
Hi Blake,
The PostGisDialect was compiled against a different version of the nHibernate assembly
Rebulding them fixed all exception.
Thanks again for your help, my friend!
Thanks for the update :)
-Blake