0

I am trying to figure out why this connection of Linq to Sql will not work.

I have the dbml and DataContext set up, and everything works fine. If I call this function from within the same project everything works fine. It is all set to public , and I want to call this function from another project. When I do so I get the following exception:

The type initializer for 'System.Data.SqlClient.SqlConnection' threw an exception.

not much more detail in that exception except this :

"Configuration system failed to initialize"

the error is being thrown on this line , which is the firstline of the function

  using (EngageDataContext db = new EngageDataContext())
        {

like I said , I know that everything is set up for the dbml , connection string and datacontext properly because it works when called from within the same project. Anyone have any idea whats going on?

Scott Selby
  • 9,420
  • 12
  • 57
  • 96
  • It might not be the same root cause, but the first Google hit for me was: http://stackoverflow.com/a/6472696/328193 – David May 30 '13 at 19:41

1 Answers1

2

Sometimes this happens if the app.config file isn't formatted correctly. This would be a starting point. I've run into this when I didn't have a connection string within the connectionString section.

dklingman
  • 236
  • 1
  • 14
  • for some reason using ConfigurationManager.ConnectionStrings[..] worked fine for a SqlDataConnection with my invalid app.config , but the dbml wasn't gonna have it – Scott Selby May 30 '13 at 20:03