1
votes

Im trying to resolve an issue where when using NHibernate with a SqlServerCeDriver that uses an image column you receive an error: "Byte array truncation to a length of 8000.". I found the following solution:

http://mgeorge-notes.blogspot.com/2009/05/nhibernate-mapping-from-binary-to.html

And created the following class:

namespace Test
{
    public class SqlServerCeDriver_ImageFix : SqlServerCeDriver
    {
        protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType)
        {
            base.InitializeParameter(dbParam, name, sqlType);

            if (sqlType is BinarySqlType)
            {

                PropertyInfo dbParamSqlDbTypeProperty = dbParam.GetType().GetProperty("SqlDbType");

                dbParamSqlDbTypeProperty.SetValue(dbParam, SqlDbType.Image, null);

            }

        }

    }
}

But when I change the NHibernate mapping from NHibernate.Driver.SqlServerCeDriver to Test.SqlServerCeDriver_ImageFix I get the error, but I am not sure why.

The inner exception is: "Could not load type Test.SqlServerCeDriver. Possible cause: no assembly name specified."

Anyone have any ideas as to what im doing wrong?

1

1 Answers

1
votes

When defining the driver in the config, define it with the AssemblyQualifiedName, i.e.:

Test.SqlServerCeDriver_ImageFix, MyAssemblyThatContainsThisType