开发者

.Net + Nhibernate + Mysql Connector 6.3.5 = Value cannot be null error

I have got a simple integration sanity test to prove that my mappings are working, originally I was using an MsSQL database server, but have now added support for MySQL (or at least I thought I had) but I keep getting the following error whenever i load the nhibernate.cfg.xml file up.

SetUp : System.ArgumentNullException : Value cannot be null.

Parameter name: stream

Here is the config file:

<?xml version="1.0" encoding="utf-8" ?>

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">

  <session-factory>

    <!-- Connection config -->
    <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.MySQLDialect</property>
    <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property开发者_JAVA技巧>
    <property name="connection.connection_string">Server=localhost;Database=xxxxx;User ID=root;</property>
    <property name="show_sql">true</property>

    <!-- Mapping config -->
    <mapping assembly="xxxxx.xxxxx"/>

  </session-factory>

</hibernate-configuration>

The interwebs seem to have some info on this being a MySQL Connector issue, but only in versions prior to 6.1, and there are no solutions i found, just people saying to update. However im on the latest version. Any help would be great!

** Edit **

Here is the stack trace incase it helps diagnose the underlying issue:

at System.IO.StreamReader..ctor(Stream stream, Encoding encoding, Boolean detectEncodingFromByteOrderMarks, Int32 bufferSize)
at System.IO.StreamReader..ctor(Stream stream)
at MySql.Data.MySqlClient.SchemaProvider.GetReservedWords()
at MySql.Data.MySqlClient.SchemaProvider.GetSchemaInternal(String collection, String[] restrictions)
at MySql.Data.MySqlClient.ISSchemaProvider.GetSchemaInternal(String collection, String[] restrictions)
at MySql.Data.MySqlClient.SchemaProvider.GetSchema(String collection, String[] restrictions)
at MySql.Data.MySqlClient.MySqlConnection.GetSchema(String collectionName, String[] restrictionValues)
at MySql.Data.MySqlClient.MySqlConnection.GetSchema(String collectionName)
at NHibernate.Dialect.Schema.AbstractDataBaseSchema.GetReservedWords()
at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.GetReservedWords(Dialect dialect, IConnectionHelper connectionHelper)
at NHibernate.Tool.hbm2ddl.SchemaMetadataUpdater.Update(ISessionFactory sessionFactory)
at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners)
at NHibernate.Cfg.Configuration.BuildSessionFactory()
at xxxxx.unittests.logic.mappings.MappingSanityTests.PreTestSetup() in C:\Documents and Settings\xxxxx\My Documents\Projects\Other\xxxxx\src\tests\xxxxx.integrationtests\logic\mappings\MappingSanityTests.cs:line 22


After looking around the net a bit more I found a lone post on the Nhibernate forums that has fixed my issue, don't honestly know why the keywords are such a problem but im not going to argue with it.

<property name="hbm2ddl.keywords">none</property>

Put that in your config file within your session factory and all it all plays together nicely.


Just guessing here. The argument name "stream" assumes that something gets deserialized. If the mapping assembly you are providing does not exist, it may be null. Just try to remove the mapping element to see if it does not result in the same error.

If it is something else, take a look at the stack trace or debug into NH code to find the place where the error comes from.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜