Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Question
Thursday, March 1, 2012 10:46 AM | 1 vote
Hello
I installed Visual Studio 11 Pro today and it looks really awesome!
Unfortunately it killed my abillity to connect to my remote MS SQL Server 2008 R2 Express (v. 10.50.2500) through Visual Studio (both 2010 and 11 Beta). For some reason i have no problems connecting to my local database which is version 10.0.5500.
I can connect to the remote database through SQL Server Management Studio 2008. This problem only exist in Visual Studio.
The error i get when i try to connect is:
Cannot connect to xxx.xxx.xx.xxx\SQLEXPRESS.
Additional information:
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 0 - Something with: "Timeout was cancelled" in my own language .)
(Microsoft SQL Server, Error: 258)
I'm pretty lost here as everything seems to work except in Visual Studio :/
Hope someone can help. Thanks.
All replies (38)
Monday, March 12, 2012 6:58 PM âś…Answered | 3 votes
I was able to solve this by uninstalling the .NET Framework 4.5 Beta and reinstalling Framework 4.0. I didn't realize when uninstalling VS11 that the Framework stuck around.
Friday, March 2, 2012 3:29 AM
Hi Heu,
This may answer the problem that you encountered: http://social.msdn.microsoft.com/Forums/en/vssetup/thread/560edc22-aca3-423f-9689-db8334923ed6
Sincerely,
Helen Zhou [MSFT]
MSDN Community Support | Feedback to us
Monday, March 5, 2012 7:26 AM
Thank you very much for your reply.
I tried what you've suggested, but it didn't work unfortunately :/
I'm really lost here :(
Monday, March 5, 2012 7:52 AM
All my other programs i have either made or uses a connection to an external database is affected by this.
So it's more like there's something wrong with .Net 4.5 than Visual Studio itself.
Tuesday, March 6, 2012 5:56 AM
I have same question!
How to Fix it?
Tuesday, March 6, 2012 7:00 AM
Hi Heu, I have some questions for you if you don't mind.
1. Could you explain how and when are you getting that particular error thrown back at you? Is it when the program is running and making a connection to the database?
2. Are you also able to add a new data source in VS11 and list out all the tables from the database that you have selected?
3. Are you on a fresh Win 8 CP install?
4. If no, which OS did you upgrade from? Win 8 DP or Win 7?
5. Have you tried restarting the SQL Server service and see if that helps?
6. Have you tried disabling the Named Pipes option in the SQL Server configuration manager and see if that helps?
7. Have you attempted to repair VS 2010 and/or VS 11?
Tuesday, March 6, 2012 10:04 AM
Of course!
1. I have made a WinForm application that connects to a remote database. When it tries to connect i get this error: A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 0). - Same error as in VS
2. When i add a new connection in both VS11 and VS2010 using the .Net Framework Data Provider for SQL Server i get the error. It only happens when i connect to a remote server. If i connect my local computer it works just fine. Another thing is that if i use the .Net Framework Data Provider for OLE DB it can connect to the remote server, which i find kinda odd.
3. I'm on Windows 7 which i have used for 8 months or so.
4. Haven't upgraded my OS. It's as it's always been.
5. Yes.
6. Yes.
7. VS11 yes VS2010 no - will try that.
Tuesday, March 6, 2012 1:57 PM
Hi Heu, thank you for your answers. I still have a few more questions if you don't mind.
1. Do you have any firewall software turned on? If yes, does the error still show when it is off?
2. Do you happen to be using the BCrypt.Net library in your application?
3. Do you have forced encryption turned on for your remote sql server? You can check this by going into SQL Server Configuration, then expand SQL Server Network Configuration, then right click the instance name, and then Properties. Also, please look at the Ceritificate tab and check if there are any certificates there?
4. Could you please show us your connection string to the remote server?
Tuesday, March 6, 2012 2:52 PM
Reinstalling didn't help :(
Wednesday, March 7, 2012 9:51 AM
Hello,
I have exactly the same problem on windows 7.
- Can't connect SQL Server or express versions in visual studio 2010 or 11 beta
- but can connect via SQL Server Management Studio 2008
- All own programs try to connect remote serves are blocked too on this computer - same error posted
Answers to forum questions:
- Do you happen to be using the BCrypt.Net library in your application? No
- Do you have forced encryption turned on for your remote sql server? - No
- look at the Ceritificate tab and check if there are any certificates there? - No
- Deleting C:\Documents and Settings\YOUR_USERNAME\Local Settings\Application Data\Microsoft\Microsoft SQL Server Data\SQLEXPRESS
also did not work for me.
I hope someone could help us. Thanks a lot.
Wednesday, March 7, 2012 9:59 AM
1. Yes and sadly yes :( I actually had my hopes up for this as i recently installed Kaspersky Pure, but still no difference when it's completely turned off.
2. Nope
3. No forced encryption and no certificates anywhere.
4. Data Source=***.***.***\SQLEXPRESS;Initial Catalog=DB;Persist Security Info=True;User ID=*****;Password=***********
Monday, March 12, 2012 7:15 AM
Can it really be impossible to solve? :(
I guess it's time for a reinstall of windows :(
Monday, March 12, 2012 7:23 AM
Umm, I guess there may be some encryption problems, rather than Visual Studio 2010/11 problem, since if encryption involved on the connections there, Pre-login handshake errors can indicate an SSL failure. And hope this two links would be helpful for you:
A connection was successfully established with the server, but then an error occurred during the pre-login handshake
http://forums.whirlpool.net.au/archive/799011
If all those doesn't help, you may have a try to post the question on SQL Server Data Access forums which seems more appropriate.
Sincerely,
Helen Zhou [MSFT]
MSDN Community Support | Feedback to us
Monday, March 12, 2012 4:05 PM
I am also having this same problem. It didn't start until after I installed VS 2011 Pro Beta. Now I can't connect to remote databases, but local databases work.
Here is the code I'm using to connect:
using(IDbCommand command = new SqlCommand())
{
command.CommandTimeout = 2000000;
command.CommandText = "sp_databases";
command.CommandType = CommandType.StoredProcedure;
command.Connection = new SqlConnection("Data Source=remoteservername;User ID=username;Database=master;Encrypt=False");
IDbDataAdapter adapter = new SqlDataAdapter();
adapter.SelectCommand = command;
DataSet set = new DataSet();
adapter.Fill(set); //exception happens here
command.Connection.Close();
}
I have sent this code to another developer who installed VS11 beta and he is not having any problems. I have tried uninstalling VS11 beta, but the problem still persists....help!!!
This is the exception that is thrown:
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: SSL Provider, error: 0 - The wait operation timed out.)
Stack trace:
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.ConsumePreLoginHandshake(Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean& marsCapable)
at System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, Boolean withFailover)
at System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean ignoreSniOpenTimeout, TimeoutTimer timeout, SqlConnection owningObject, Boolean withFailover)
at System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(ServerInfo serverInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, SqlCredential credential, TimeoutTimer timeout)
at System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, TimeoutTimer timeout, SqlConnectionString connectionOptions, SqlCredential credential, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, SqlConnection owningObject, Boolean redirectedUserInstance)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection)
at System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options, DbConnectionPoolKey poolKey)
at System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.Common.DbDataAdapter.FillInternal(DataSet dataset, DataTable[] datatables, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet, Int32 startRecord, Int32 maxRecords, String srcTable, IDbCommand command, CommandBehavior behavior)
at System.Data.Common.DbDataAdapter.Fill(DataSet dataSet)
Monday, March 12, 2012 4:23 PM
I have created a post over in the SQL Server Data Access forum describing my issues.
Tuesday, March 13, 2012 8:53 AM
Awesome!!! This solved my problem!!
Apparently .Net 4.5 is the root of all evil ;)
Thanks a lot!
Tuesday, March 13, 2012 9:53 AM
Hi David,
Glad you have found the root cause and share the solution of the problem.
Sincerely,
Helen Zhou [MSFT]
MSDN Community Support | Feedback to us
Wednesday, March 14, 2012 6:11 AM
Thanks!!! I have solved my problem with your advice. I realized vs2011 is the root of all evil until i have reinstalled the system two times. Damn vs2011!
Thursday, April 19, 2012 11:03 PM
For those who have uninstalled Visual Studio 11 and are now successfully connecting via Visual Studio 2010, can you please explicitly enable encryption in your connection string (i.e. add "Encrypt=True") and see if Visual Studio 2010 is still working.
Thanks
Sunday, April 22, 2012 8:41 PM
guys please fill me in here.... i removed .NET 4.5beta and re-installed .NET 4.0 and it didn't solve my problem. rather vs2011 refuses to work with .NET 4.0. please explain... i still have thesame problem with connecting to remote database with vs2011.
Thursday, May 3, 2012 4:28 PM
I tried this yesterday and it is still working if you also set TrustServerCertificate to true.
Derek
Thursday, May 3, 2012 4:30 PM
I am not sure if you meant you left vs 11 installed and just uninstalled the 4.5 framework. If this is the case I am pretty sure that VS 11 will not continue to work. You have to uninstall them both. You may want to do a repair on VS 2010 as well.
Derek
Thursday, May 3, 2012 6:33 PM
I tried this yesterday and it is still working if you also set TrustServerCertificate to true.
Derek
Thank you for trying this Derek.
I have one more thing that I'd like you to try: Can you please turn on asynchronous support ("Async=true" in your connection string) and see if you can still connect?
Daniel Paoliello [MSFT]
ADO.Net Managed Providers and DataSet
Thursday, May 3, 2012 8:16 PM
I will try it in a bit. I have installed VS 11 again (I am using Try&Decide from Acronis so I can just throw away my changes). The strange thing is I have another machine which works. I am trying to figure out what is different.
Derek
Thursday, May 3, 2012 8:47 PM
Data Source=<mywebsite>.com;Initial Catalog=<MyDB>;Persist Security Info=True;User ID=PermitMasterAdmin;Asynchronous Processing=True;Encrypt=True;TrustServerCertificate=True
This is the connection string generated by the connection dialog from within VS2010.
Just so we are clear. This is basically a clean VS2010 install (see above message).
These connection properties worked.
Derek
Thursday, May 3, 2012 9:04 PM
One other piece of information ... If I am connecting to a remote server within my corporate network where I have control of the servers I can enable Named Pipes and set the network library in the connection string to named pipes and it works. This seems to be strictly a TCP problem.
Derek
Thursday, June 14, 2012 1:14 AM
Thanks for the solution.
However even with the .NET 4.5 RC, I still having this issue.
Has there been a solution to the issue - so that i can finally install the VS 2011 and .NET 4.5.
Thanks
Sunday, July 1, 2012 3:29 PM
Hello, guys
i had thesame issue with vs2011 and now again with vs 2012RC. i just hope .NET 4.5 and .NET 4.5RC is not wack?
i'm still stuck with my vs2010.
any solution to this issue?
Friday, July 6, 2012 1:41 PM | 1 vote
I have an update on this issue. It turns out this is being caused by a code change in the .NET framework 4.5 that is interfering with 3rd party software that intercepts Winsock calls. (This kind of software is called a Base Service Provider, or Layered Service Provider). In short, the 3rd party is going to have to update their software to support .NET 4.5.
Here is the relevant Connect article:
You can use the instructions in the following article to see if you have such a BSP/LSP installed:
http://support.microsoft.com/kb/2568167
Saturday, August 4, 2012 11:56 AM
I also has this issue after installing Team Foundation Server Express which requires IISExpress and .NET 4.5.
My issue was connecting to the instance on a server on the same network, using Management Studio, Visual Studio and the ASPNET_SQL tool.
The fix for me was to enable Named Pipes (already enabled) on the remote server and DISABLE TCP IP on the remote sql server.
The problem really for me was trying to run the aspnet_sql tool, it must default to TCP and i couldnt find a method of forcing it to use named pipes, so i disabled TCP and it worked.
I realise this is a workaround and i also realise the issue is with a custom LCP in winsock. I use a Bigfoot Networks Killer network card which requires custom LCP so wasnt sure how to fix.
Microsoft, sort this out, clearly many are having these issues, the days i've spent working this out... and still not fixed. Think of the alternate methods to resolve > UNINSTALL, is that what you want??
Wednesday, August 15, 2012 5:56 AM
yes i agree but that is a situation when you have access to the remote server. wat if i don't. it means i'm stock! microsoft please do something about this. i can't migrate to vs2012 'cos of this.
Friday, August 24, 2012 9:29 AM
I also have the same problem. And i installed the vs2012 RTM version....
Microsoft didn't have any testing to release the rtm version of vs2012...
and what i want talk to microsoft was : WTF!!!!!!!!
Monday, September 3, 2012 4:49 PM | 7 votes
Sick of the problem? Dont know or care what winsock is or any of this low level crap means.
Go to a command prompt
do this
netsh Winsock reset
go on with your life and be happy.
Chris McGinn
Thursday, September 6, 2012 9:35 PM
Tried this with no luck :(
Derek
Thursday, September 6, 2012 10:23 PM
Ok,
The solution (not really a final I hope) after reading everything I could about this was to uninstall my anti-spyware software which laid down a LSP provider.
This needs to be fixed because I cannot live without this for long. But at least it is working now.
Derek
Tuesday, November 27, 2012 1:52 PM
Sick of the problem? Dont know or care what winsock is or any of this low level crap means.
Go to a command prompt
do this
netsh Winsock reset
go on with your life and be happy.
Chris McGinn
You da man! Works.
fac ut vivas
Sunday, December 2, 2012 5:44 PM
It works thank you very much !
Tuesday, September 10, 2013 1:00 PM
Thanks a lot Chris McGinn
Kamran Shahid Application Developer (MCP,MCAD,MCSD.NET,MCTS,MCPD.net[web])