dataConfiguration element is not declared

Topics: Data Access Application Block
Jul 17, 2007 at 7:31 PM
I am building a web app in VS 2005. I have the May 2007 3.1 release of the Enterprise libaray. When I run the app with the debugger, I get "dataConfiguration element is not declared" . Any ideas on how to fix this?

Jul 17, 2007 at 7:47 PM
Hi,

Does your application raise an exception? What's the stack trace? What does your configuration file look like? How did you author the configuration file?
You need to provide additional information to get precise help. However, from the information you did provide my bet is that the configuration file is invalid.

Regards,
Fernando
Jul 17, 2007 at 9:53 PM
I agree the confiq file is the issue, however I cannot find a sample of a valid config file. The config file was created by using the enterprise library tool and looks like

Web Config


<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

</configSections>


App config

<configuration>

<dataConfiguration defaultDatabase="Connection String" />
<connectionStrings>
<add name="Connection String" connectionString="Data Source=INS-97BCC72BCB9;Initial Catalog=Northwind;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
</configuration>


exception is

Invalid section name. The section 'dataConfiguration' does not exist in the requested configuration file 'c:\inetpub\wwwroot\DataBlock\web.config' or the file 'C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config'. Make sure that the 'enterpriseLibrary.configurationSections' configuration section exists in one of the files and that the section 'dataConfiguration' is defined.


Jul 17, 2007 at 11:06 PM
Hi,

You should have a single web.config file; app.config files are for windows applications.
You can use the configuration tool to edit the web.config file, and the result should be a single file with both the <configSections> and the <dataConfiguration> elements.

Fernando
Jul 18, 2007 at 1:07 AM
The configuration tools creates both files, so the must be an issue with it, I can try reinstalling the tool. In the mean time does anyone have an example of a proper web config file?

Thanks,
Jul 18, 2007 at 2:34 AM
Hi,

This is strange. Exactly how are you creating and saving the file? The tool should save to a single file.
Are you using the VS integrated version of the tool or the stand alone exe?

An appropriate configuration file should consist of the of both the <section> element in configSections and the <dataConfiguration> element. The Data block quickstart should give you a sample app.config file; a web.config file should be similar.

Fernando
Jul 18, 2007 at 4:47 PM
I've copied the files from the quick starts and still the issue exists.

I'm trying to use the .exe tool. The integrated tool seems to do nothing.

The issue is with debugging in VS 2005. This article (http://www.codeproject.com/dotnet/EntLibJune2005_VS2005.asp?df=100&forumid=250690&exp=0&select=1333626) address the issue. However it's hard to believe that this code would not be compatable with VS 2005.
Jul 18, 2007 at 5:00 PM
Hi,

I tried a quick repro and it worked as expected. Can you create a minimal repro that would show this behavior?

The post you are referring to is quite old, and it refers to EntLib v1. It is not comparable to EntLib v3.1, as the configuration serialization changed dramatically.

What do you mean by "The integrated tool seems to do nothing"?

My repro consisted of a simple web site. I added a button and a text box to the page, and for the button click handler I wrote this code:

protected void Button1_Click(object sender, EventArgs e)
{
Database db = DatabaseFactory.CreateDatabase();
this.TextBox1.Text = db.ConnectionStringWithoutCredentials;
}

I added a web.config file and edited it with the integrated tool, by adding a connection string and setting it as the default. The web.config file was updated as expected.
I added references to the common, data and object builder binaries.

I got the same result from running and debugging the app; after clicking the button the text on the text box was updated to the connection string. What is different in your scenario?

Fernando
Jul 18, 2007 at 7:26 PM

OK, I got it to work. I reinstalled the data blocks and tried editing the web config from the .exe. That entered the following line in the config

"<configSections>
<section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=3.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
</configSections>"

I tried the integrated tool to edit it for a connection string. I enteredt the info and seledted save, but it didnot up date the file.

I copied the following from the quick start confiq file and it worked.

<dataConfiguration defaultDatabase="DataAccess" />
<connectionStrings>
<add name="DataAccess" connectionString="Data Source=INS-97BCC72BCB9;Initial Catalog=Northwind;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>

Not sure about the tools but thank you for your help