Wrote functional tests using MS test suite against MVC controllers on a 64-bit machine. These tests would perform CRUD operations in the database. The web applications worked fine. However, when I ran my functional tests, I got this error “provider: SQL Network Interfaces, error: 26 – Error Locating Server/Instance Specified”.

Knowing the web applications worked fine, I immediately executed the following sql to verify the sql connection existed, and couldn’t find the associated sql connection.

select top 100 * from sys.dm_exec_connections 
where client_net_address like '%xyz'
order by last_read desc

 

I then executed netstat in command line in my local machine to verify whether a tcp/ip connection was attempted, and still couldn’t find the lower level tcp/ip connection. At this moment, I knew the tests haven’t reached making the connection step yet.

netstat -ano | findstr ".xyz"

 

After debugged, I found out that MS tests fetched connection strings from this location,

C:\\Windows\\Microsoft.NET\\Framework\\v4.0.30319\\Config\\machine.config

instead of x64 location used by web apps,

C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\Config\\machine.config

So I added the connection strings to the right location, and functional tests passed. So make sure that machine.config files in both locations match.

Advertisements