Search code examples
sql-servervisual-studio-2013sqlconnection

Connecting to SQL Server DB through VS2013 website completely hangs; takes forever


Ever since yesterday, in spite of not having installed any new applications or updates, I started getting connection problems upon locally debugging/running pretty much all of my websites that make use of an external SQL Server. Connecting with the concerning database server through SQL Server Management Studio is working as normal, and all databases are running and accessible. These same websites are also running on a separate production server (using the same code and external SQL Server databases).

Upon further investigation, I found that Visual Studio 2013 is the culprit. After debugging one of the concerning websites, the web site completely freezes at the following code:

using (SqlConnection QueryConnection = new SqlConnection(SomeConnectionString))
{
    // This takes forever to reach
}

A breakpoint on the 'using' line is the last point reached upon debugging. My webbrowser will open but the website will keep loading forever. After literally about 10 minutes the website will finally show up and I can use it as normal, until I do something that requires recompilation and the same things happens again.

Even explicitly stating a 'Connection Timeout' in the connection string doesn't seem to be doing anything.

It seems that my VS2013 is all of a sudden unable to establish a simple SqlConnection. I already tried repairing both my .NET 4.5.2 installation and Visual Studio, I reset my VS2013 settings and deleted everything VS2013 related in the AppData folder, to no avail...

Anyone else experiencing this? Or even better, anybody have a clue on how to fix this?


Solution

  • This mystery had me baffled and I STILL don't quite know what happened. In the end I did a VS2013 reinstall which solved this issue.