The requested .Net Framework Data Provider's implementation does not have an Instance field of a System.Data.Common.DbProviderFactory derived type.

Jan 19, 2012 at 8:37 AM
Edited Jan 19, 2012 at 10:55 AM

Hi all,

I use ODP.NET and version 4.1 of the Enterprise Library, vs 2008. And all is OK.

Now, migrate using ODP.NET Oracle.DataAccess 4.112.2.0 and version 5.0.414.0 of the Enterprise Library, vs 2010, .net 4.0.

Now,  I have download source code of http://entlibcontrib.codeplex.com/

I open Data.OdpNet.QuickStarts.sln and change references to Enterprise Library 5.0.414.0. and change Target Framework to .NET 4.0. Now it works using right configuration.

 

I have any unit test that using DbProviderFactories.GetFactory(providerName);

providerName: EntLibContrib.Data.OdpNet

and I get this error: Conectar_con_EntLib_Contrib_y_OdpNet_Test threw exception: System.InvalidOperationException: The requested .Net Framework Data Provider's implementation does not have an Instance field of a System.Data.Common.DbProviderFactory derived type.


System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)

System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)

ConexionesTests.Conectar_con_EntLib_Contrib_y_OdpNet_Test() in UnitTests\Data.Tests\ConexionesTests.cs: line 126

 

what about DbProviderFactories.GetFactory ? Any solution about it ?

 

Thanks in advanced.

References EntLib Forum: http://entlib.codeplex.com/discussions/215290

http://entlibcontrib.codeplex.com/discussions/286047#post726532

 

 

 [TestMethod]
        public void Conectar_con_EntLib_Contrib_y_OdpNet_Test()
        {
            var key = "ConnectionStrings.Oracle.EntLibContrib";

            var cs = System.Configuration.ConfigurationManager.ConnectionStrings[key].ConnectionString;
            string connectionString = ConfigurationManager.ConnectionStrings[key].ConnectionString;
            string providerName = ConfigurationManager.ConnectionStrings[key].ProviderName;

            //Database db = DatabaseFactory.CreateDatabase(key);
            Database db = EnterpriseLibraryContainer.Current.GetInstance<Database>(key);

            TestContext.WriteLine("connectionString: " + connectionString);
            TestContext.WriteLine("providerName: " + providerName);

            DbProviderFactory factory = DbProviderFactories.GetFactory(providerName);

            using (DbConnection connection = factory.CreateConnection())
            {
                connection.ConnectionString = connectionString;

                connection.Open();

                TestContext.WriteLine("Estado Conexi�n: " + connection.State);
                connection.Close();
            }

        }

Coordinator
Feb 3, 2012 at 7:06 AM

Hi kiquenet,

Indeed, using DbProviderFactories.GetFactory thrown the mentionned exception. Expect a code fix to be released soon.

Cheers,

Jeremi


Coordinator
Feb 3, 2012 at 9:16 AM

The fix has been released and can be downloaded from the Source Code section.

Let me know how it goes.

Regards,

Jeremi

Feb 8, 2012 at 9:30 AM

Now, it's ok, thanks