DbProviderFactoryInvariantName invalid

Posts   
 
    
Posts: 27
Joined: 23-Mar-2012
# Posted on: 22-Feb-2013 10:11:13   

Hi all,

I had deployed my app to my client computer and when i run it, it had error message saying : DbProviderFactoryInvariantName is set to an invalid provider factory name.

On my form_load event i use this code : CommonDaoBase.ActualConnectionString = Settings1.Default.ConString;

I use dotConnect 6.7 and visual studio 2010 pro.

What could be the cause of this error?

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39896
Joined: 17-Aug-2003
# Posted on: 22-Feb-2013 11:36:21   

Please check whether the dbproviderfactory is defined in the machine.config file for the .net version you're using. Their installer normally does that. If you just copied over their assemblies, you won't have the dbproviderfactory declaration in the machine.config file.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 27
Joined: 23-Mar-2012
# Posted on: 22-Feb-2013 11:46:55   

Thanks Otis for the reply .

in my machine.config :

<DbProviderFactories>
      <add name="Odbc Data Provider" invariant="System.Data.Odbc" description=".Net Framework Data Provider for Odbc" type="System.Data.Odbc.OdbcFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <add name="OleDb Data Provider" invariant="System.Data.OleDb" description=".Net Framework Data Provider for OleDb" type="System.Data.OleDb.OleDbFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <add name="OracleClient Data Provider" invariant="System.Data.OracleClient" description=".Net Framework Data Provider for Oracle" type="System.Data.OracleClient.OracleClientFactory, System.Data.OracleClient, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <add name="SqlClient Data Provider" invariant="System.Data.SqlClient" description=".Net Framework Data Provider for SqlServer" type="System.Data.SqlClient.SqlClientFactory, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      <add name="Microsoft SQL Server Compact Data Provider" invariant="System.Data.SqlServerCe.3.5" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
      <add name="dotConnect for MySQL" invariant="Devart.Data.MySql" description="Devart dotConnect for MySQL" type="Devart.Data.MySql.MySqlProviderFactory, Devart.Data.MySql, Version=6.70.293.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.6.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>

What's next?

Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 22-Feb-2013 12:32:58   

Which machine.config is this one? (in which folder) And does it match the .NET Framework and CPU architecture you are targeting.

Posts: 27
Joined: 23-Mar-2012
# Posted on: 22-Feb-2013 12:49:25   

the folder is in C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG

And does it match the .NET Framework and CPU architecture you are targeting.

After i read your question i just realized i had look on wrong folder. I'm targeting using .NET Framework 4 that run on x64 so i should look it at C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config ??

This is from my machine.config on C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config :

<DbProviderFactories>
      <add name="Microsoft SQL Server Compact Data Provider" invariant="System.Data.SqlServerCe.3.5" description=".NET Framework Data Provider for Microsoft SQL Server Compact" type="System.Data.SqlServerCe.SqlCeProviderFactory, System.Data.SqlServerCe, Version=3.5.1.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" />
      <add name="dotConnect for MySQL" invariant="Devart.Data.MySql" description="Devart dotConnect for MySQL" type="Devart.Data.MySql.MySqlProviderFactory, Devart.Data.MySql, Version=6.70.293.0, Culture=neutral, PublicKeyToken=09af7300eec23701" />
      <add name="MySQL Data Provider" invariant="MySql.Data.MySqlClient" description=".Net Framework Data Provider for MySQL" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data, Version=6.6.4.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d" />
    </DbProviderFactories>


Walaa avatar
Walaa
Support Team
Posts: 14995
Joined: 21-Aug-2005
# Posted on: 22-Feb-2013 15:02:48   

Could you please post the stack trace?

Posts: 27
Joined: 23-Mar-2012
# Posted on: 23-Feb-2013 00:46:19   
SD.LLBLGen.Pro.ORMSupportClasses.ORMGeneralOperationException: DbProviderFactoryInvariantName is set to an invalid provider factory name.
   at SD.LLBLGen.Pro.ORMSupportClasses.DbProviderFactoryInfo.get_FactoryToUse()
   at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.CreateConnection(String connectionString)
   at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformFetchEntityAction(IEntity entityToFetch, ITransaction containingTransaction, IPredicateExpression selectFilter, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields)
   at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.FetchExisting(IEntity entityToFetch, ITransaction containingTransaction, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields)
   at dbShowRoom.Data.EntityClasses.PengaturankreditEntity.Fetch(Byte kodePengaturanKredit, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields)
   at dbShowRoom.Data.EntityClasses.PengaturankreditEntity.FetchUsingPK(Byte kodePengaturanKredit, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields)
   at dbShowRoom.Data.EntityClasses.PengaturankreditEntity.FetchUsingPK(Byte kodePengaturanKredit)
   at SistemInformasiRetail.FrmMain.FrmMain_Load(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39896
Joined: 17-Aug-2003
# Posted on: 23-Feb-2013 10:45:34   

Please call in some console application, using the same .net version: var factories = DbProviderFactories.GetFactoryClasses();

the 'factories' variable will then contain a datatable. It should contain a row for 'Devart.Data.MySql', that's the factory our runtime requests. From the looks of it, it does contain the definition, in the config file at least. However it might be .net can't instantiate the factory. So it might also be a good idea for you to ask devart what could be wrong. e.g. if you don't have the row in the table defined.

Frans Bouma | Lead developer LLBLGen Pro
Posts: 27
Joined: 23-Mar-2012
# Posted on: 23-Feb-2013 13:00:30   

Thanks Otis for the reply.

I tried to use this code on my frmMain_Load :

var factories = DbProviderFactories.GetFactoryClasses(); MessageBox.Show(factories.Rows.Count.ToString());

The messagebox shows 7 include dotconnect for mySQL and mysql data provider.

Posts: 27
Joined: 23-Mar-2012
# Posted on: 25-Feb-2013 03:25:15   

The problem had been solved.

Turn out that there is some reference from devart that need to be add.

Everything is ok now.

Thanks all for the help.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39896
Joined: 17-Aug-2003
# Posted on: 25-Feb-2013 10:03:13   

Odd. Did devart tell you to add the reference? As DbProviderFactory was designed to avoid references directly to ado.net providers...

Frans Bouma | Lead developer LLBLGen Pro