c# - Unable to load Custom ADO.NET provider for NHibernate -


i using devart postgres driver ado.net provider nhibernate. since nhibernate not support devart postgres driver, wrote custom driver class based on reflectionbaseddriver. here code:

namespace postgresdriver.dbdriver {     class devartpgdriver : reflectionbaseddriver     {         public devartpgdriver()             : base(             "devart.data.postgresql",             "devart.data.postgresql.pgsqlconnection",             "devart.data.postgresql.pgsqlcommand")         {         }          public override string namedprefix         {             { return ":"; }         }          public override bool usenamedprefixinparameter         {             { return true; }         }          public override bool usenamedprefixinsql         {             { return true; }         }          public override bool supportsmultipleopenreaders         {             { return false; }         }          protected override bool supportspreparingcommands         {             { return true; }         }          public override iresultsetscommand getresultsetscommand(nhibernate.engine.isessionimplementor session)         {             return new basicresultsetscommand(session);         }          public override bool supportsmultiplequeries         {             { return true; }         }          protected override void initializeparameter(idbdataparameter dbparam, string name, nhibernate.sqltypes.sqltype sqltype)         {             base.initializeparameter(dbparam, name, sqltype);              // since .net currency type has 4 decimal places, use decimal type in postgresql instead of native 2 decimal currency type.             if (sqltype.dbtype == dbtype.currency)                 dbparam.dbtype = dbtype.decimal;         }     } } 

i have added devart.data , devart.data.postgresql dlls references in solution , set 'copy local' property true. have added following section in app.config:

  <runtime>     <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">       <qualifyassembly partialname="devart.data.postgresql"             fullname="devart.data.postgresql, version=7.2.80.0, culture=neutral, publickeytoken=09af7300eec23701">       </qualifyassembly>     </assemblybinding>     <assemblybinding xmlns="urn:schemas-microsoft-com:asm.v1">       <qualifyassembly partialname="devart.data"             fullname="devart.data, version=5.0.872.0, culture=neutral, publickeytoken=09af7300eec23701">       </qualifyassembly>     </assemblybinding>   </runtime> 

here hibernate.cfg.xml:

<session-factory name="nhsessionfactory">     <property name="connection.provider">nhibernate.connection.driverconnectionprovider</property>     <property name="connection.driver_class">postgresdriver.dbdriver.devartpgdriver, devart.data.postgresql</property>     <property name="dialect">nhibernate.dialect.postgresql82dialect</property>     <property name="connection.connection_string">user id=***;password=***;host=localhost;port=5433;database=***;</property>     <property name="show_sql">true</property>         <property name="format_sql">true</property   </session-factory> 

when call sessionfactory = cfg.buildsessionfactory(); following error: "could not load type 'postgresdriver.dbdriver.devartpgdriver' assembly 'devart.data.postgresql, version=7.2.80.0, culture=neutral, publickeytoken=09af7300eec23701'."

when try instantiate driver class devartpgdriver dr = new devartpgdriver(); error under static members:

nhibernate.driver.reflectionbaseddriver.reflectiontypedproviderexceptionmessagetemplate "the idbcommand , idbconnection implementation in assembly {0} not found. ensure assembly {0} located in application directory or in global assembly cache. if assembly in gac, use <qualifyassembly/> element in application configuration file specify full name of assembly." 

what missing? have troubleshooted issue hours without success. please help!

after several hours of trial , error able resolve issue:

instead of:

public devartpgdriver()         : base(         "devart.data.postgresql",         "devart.data.postgresql.pgsqlconnection",         "devart.data.postgresql.pgsqlcommand")     {     } 

it should have been:

public devartpgdriver()         : base(         "devart.data.postgresql",         "devart.data.postgresql",         "pgsqlconnection",         "pgsqlcommand")     {     } 

i added nhproperties.add(nhibernate.cfg.environment.hbm2ddlkeywords, "none"); nhibernate configuration. rippo direction.


Comments

Popular posts from this blog

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -