InvalidOperationException: GetConfig was called during configuration initialization

K

kosta

hello!

I have this code:

public static DataSet DSet(String sql)
{
OleDbConnection con = new OleDbConnection();
con.ConnectionString =
ConfigurationSettings.AppSettings["conString"];
OleDbCommand cmd = new OleDbCommand(sql,con);
OleDbDataAdapter adp = new OleDbDataAdapter(cmd);
DataSet ds = new DataSet();
adp.Fill(ds);
return ds;
}

it ran fine untill about yesterday, but suddnely now i always get an
InvalidOperatioException (referring to the second line of the
function)... the
help text is: GetConfig was called during configuration initialization

i have no idea why is suddnely started appearing... please help!
thanks!

Best Regards,
Kosta.
 
G

Guest

I had the same problem this week when I attempted converting and subsequently
running my C# app developed under Visual Studio 2003, to the Beta of C# 2005
Express

It was in a similar place too, when setting the connection string of a
database connection, although my code didnt attempt to pull the connection
string from the config file.

I eventually tracked it down to being caused by bad/invalid text in the
app.config file. In the configSections I had a section with a name
containing spaces and commas, this seemed to be the culprit. I tried a
number of variations and found this was the cause of my grief, so I assume
C#2.0/.NET 2.0 is a bit more picky about the structure of the file. In my
case, I wasnt even accessing the section, but I can only assume that setting
the connection string of SqlConnection shomehow forces the reading/validating
of the config file.

Hope this helps

Ms Jackson
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top