ASMX InvalidOperationException being thrown when setting up sqlconnection to database

80 Views Asked by At

A bit of a legacy development, however, this is our final push until we start on a new project using newer technologies.

As the title states, this is an asmx webservice that I am trying to debug. It has a WPF interface for the user. The asmx webservice provides this interface with data (a datagrid and few dropdowns) to allow us to export this data.

For the last few iterations, I need to create a new page that takes in a list of items from the webservice and make it the source for the grid/dropdowns and it is built. Though I am coming across issues running the webservice sql functionality and I have pinned it down to this line:

SqlConnection sql_dbConn = new SqlConnection(ConfigurationManager.ConnectionStrings["SQLDataConn"].ToString());

As, it throws a null exception. What I have noticed that was strange was the service itself seemed to be throwing a bunch of errors as shown here:

enter image description here

IIS is configured and turned on as I can view it in a browser and attempt to invoke methods, but will fail.

This project (along with the other 4 in this project) are all on .NET 4.0

1

There are 1 best solutions below

0
On

Mark's comment was the correct solution.

Did not know that I was looking at the wrong configuration file.