MySqlDataDriver: Using DbProviderFactories.GetFactory instead of Reflection?
Max <[email protected]> Mon, 07 Jul 2008 21:17:05 +0200
| Newsgroups | gmane.comp.windows.dotnet.nhibernate.devel |
|---|---|
| Message-ID | <[email protected]> |
Hello, please excuse me if this is the wrong place to post this.. it's more of a development question than a usage question so I thought this would be the right place. I haven't seen this being discussed anywhere yet. The problem: NHibernate doesn't find the MySql.Data.dll unless it is either copied to the application directory or the app.config has been correctly configured to redirect requests to the GAC. The exception's message is: "Could not create the driver from NHibernate.Driver.MySqlDataDriver" A user posted the same problem in the forums: http://forum.hibernate.org/viewtopic.php?p=2374130 I had a quick look at the class MySqlDataDriver and saw that it uses reflection to load the MySql.Data.dll and to create instances of the connection and command types. That explains the problem. I was wondering why it doesn't (additionally) try to do this using ADO's DbProviderFactories.GetFactory() method? A DbProviderFactory has methods for creating connection and command instances. This way MySql.Data.dll wouldn't have to be copied to the application directory and no additional app.config changes would be necessary. Please let me know what you think of that. Max ------------------------------------------------------------------------- Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW! Studies have shown that voting for your favorite open source project, along with a healthy diet, reduces your potential for chronic lameness and boredom. Vote Now at http://www.sourceforge.net/community/cca08