Entlib + config problem
-
Hello All, I've got a problem with EntLib 4.1 in combination with my config file. I have a class library for data access which has its own app.config file containing the information for the sql connection.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<dataConfiguration defaultDatabase="CarOmnia" />
<connectionStrings>
<add name="CarOmnia" providerName="System.Data.SqlClient" connectionString="server=(local);database=CarOmnia;User Id=xx;Password=xxxx;" />
</connectionStrings>
</configuration>Code to access the database:
public static DataSet SelectAll()
{
DataSet retValue = new DataSet();try { Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetStoredProcCommand(stpTest); retValue = db.ExecuteDataSet(cmd); } catch (Exception ex) { throw ex; } return retValue; }
With this go the following includes:
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;What am i doing wrong, i'm getting the following error on the CreateDatabase() line: {"The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, null]) failed: The value can not be null or an empty string. (Strategy type ConfiguredObjectStrategy, index 2)"}
-
Hello All, I've got a problem with EntLib 4.1 in combination with my config file. I have a class library for data access which has its own app.config file containing the information for the sql connection.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<dataConfiguration defaultDatabase="CarOmnia" />
<connectionStrings>
<add name="CarOmnia" providerName="System.Data.SqlClient" connectionString="server=(local);database=CarOmnia;User Id=xx;Password=xxxx;" />
</connectionStrings>
</configuration>Code to access the database:
public static DataSet SelectAll()
{
DataSet retValue = new DataSet();try { Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetStoredProcCommand(stpTest); retValue = db.ExecuteDataSet(cmd); } catch (Exception ex) { throw ex; } return retValue; }
With this go the following includes:
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;What am i doing wrong, i'm getting the following error on the CreateDatabase() line: {"The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, null]) failed: The value can not be null or an empty string. (Strategy type ConfiguredObjectStrategy, index 2)"}
I had the same problem the other day.... Does the config file that is in the project root directory differ from the one in the Debug directory? If I remember correctly, VS overrites the config file every time you compile or change some settings in the file. Kind regards,
The only programmers that are better C# programmers, are those who look like this -> :bob:
:)Programm3r My Blog: ^_^
-
I had the same problem the other day.... Does the config file that is in the project root directory differ from the one in the Debug directory? If I remember correctly, VS overrites the config file every time you compile or change some settings in the file. Kind regards,
The only programmers that are better C# programmers, are those who look like this -> :bob:
:)Programm3r My Blog: ^_^
-
What about the <app name>.exe.config ? Is that perhaps different? Otherwise run the Enterprise Library Configuration tool and set the values again in all config files....
The only programmers that are better C# programmers, are those who look like this -> :bob:
:)Programm3r My Blog: ^_^
-
Hello All, I've got a problem with EntLib 4.1 in combination with my config file. I have a class library for data access which has its own app.config file containing the information for the sql connection.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
</configSections>
<dataConfiguration defaultDatabase="CarOmnia" />
<connectionStrings>
<add name="CarOmnia" providerName="System.Data.SqlClient" connectionString="server=(local);database=CarOmnia;User Id=xx;Password=xxxx;" />
</connectionStrings>
</configuration>Code to access the database:
public static DataSet SelectAll()
{
DataSet retValue = new DataSet();try { Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetStoredProcCommand(stpTest); retValue = db.ExecuteDataSet(cmd); } catch (Exception ex) { throw ex; } return retValue; }
With this go the following includes:
using System.Data;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using Microsoft.Practices.EnterpriseLibrary.Data;
using System.Data.Common;What am i doing wrong, i'm getting the following error on the CreateDatabase() line: {"The current build operation (build key Build Key[Microsoft.Practices.EnterpriseLibrary.Data.Database, null]) failed: The value can not be null or an empty string. (Strategy type ConfiguredObjectStrategy, index 2)"}
Make sure you save your application. You will get this if the application is not saved OR if the app.config is missing. -Josh