31

I have a web application that is working perfectly in my system. However, when I copied it to another system, I couldn't login to the application. There is an error:

Server Error in '/' Application.
--------------------------------------------------------------------------------

Instance failure. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Instance failure.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[InvalidOperationException: Instance failure.]
   System.Data.SqlClient.TdsParser.Connect(ServerInfo serverInfo, SqlInternalConnectionTds connHandler, Boolean ignoreSniOpenTimeout, Int64 timerExpire, Boolean encrypt, Boolean trustServerCert, Boolean integratedSecurity, SqlConnection owningObject) +4858423
   System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(ServerInfo serverInfo, String newPassword, Boolean ignoreSniOpenTimeout, Int64 timerExpire, SqlConnection owningObject) +90
   System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(String host, String newPassword, Boolean redirectedUserInstance, SqlConnection owningObject, SqlConnectionString connectionOptions, Int64 timerStart) +257
   System.Data.SqlClient.SqlInternalConnectionTds.OpenLoginEnlist(SqlConnection owningObject, SqlConnectionString connectionOptions, String newPassword, Boolean redirectedUserInstance) +221
   System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, Object providerInfo, String newPassword, SqlConnection owningObject, Boolean redirectedUserInstance) +189
   System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection) +4859187
   System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnection owningConnection, DbConnectionPool pool, DbConnectionOptions options) +31
   System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject) +433
   System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject) +66
   System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) +499
   System.Data.ProviderBase.DbConnectionFactory.GetConnection(DbConnection owningConnection) +65
   System.Data.ProviderBase.DbConnectionClosed.OpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory) +117
   System.Data.SqlClient.SqlConnection.Open() +122
   System.Web.DataAccess.SqlConnectionHolder.Open(HttpContext context, Boolean revertImpersonate) +87
   System.Web.DataAccess.SqlConnectionHelper.GetConnection(String connectionString, Boolean revertImpersonation) +221
   System.Web.Security.SqlMembershipProvider.GetPasswordWithFormat(String username, Boolean updateLastLoginActivityDate, Int32& status, String& password, Int32& passwordFormat, String& passwordSalt, Int32& failedPasswordAttemptCount, Int32& failedPasswordAnswerAttemptCount, Boolean& isApproved, DateTime& lastLoginDate, DateTime& lastActivityDate) +815
   System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved, String& salt, Int32& passwordFormat) +105
   System.Web.Security.SqlMembershipProvider.CheckPassword(String username, String password, Boolean updateLastLoginActivityDate, Boolean failIfNotApproved) +42
   System.Web.Security.SqlMembershipProvider.ValidateUser(String username, String password) +78
   System.Web.UI.WebControls.Login.AuthenticateUsingMembershipProvider(AuthenticateEventArgs e) +60
   System.Web.UI.WebControls.Login.OnAuthenticate(AuthenticateEventArgs e) +119
   System.Web.UI.WebControls.Login.AttemptLogin() +115
   System.Web.UI.WebControls.Login.OnBubbleEvent(Object source, EventArgs e) +101
   System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +37
   System.Web.UI.WebControls.Button.OnCommand(CommandEventArgs e) +118
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +166
   System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
   System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
   System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053 

What could be the reason for such an error? How could I solve this?

Muhammad Akhtar
  • 51,913
  • 37
  • 138
  • 191
user85511
  • 503
  • 7
  • 14
  • 26

7 Answers7

95

Does your connection string contain a double-slash between the server name and the database instance name?

eg. localhost\\SQLEXPRESS

It should be: localhost\SQLEXPRESS

See:

http://www.hanselman.com/blog/CommentView.aspx?guid=89c01cae-e045-4b06-bff1-8dd2d596e266

Rob
  • 4,210
  • 3
  • 30
  • 25
  • I had a slightly different problem : in my case, the backslash was at the end of the servername : `Server=.\SQLEXPRESS\;Database=...`. I corrected it to : `Server=.\SQLEXPRESS;Database=...`! – Dude Pascalou Oct 15 '13 at 21:49
  • I had the same issue but the connection string was getting overridden from an environment variable I had setup – samwa Apr 19 '22 at 04:29
10

Remove double-slash

If: localhost\\SQLEXPRESS

Make: localhost\SQLEXPRESS

It worked for me.

Hoppo
  • 1,130
  • 1
  • 13
  • 32
Ashok Chhetri
  • 428
  • 6
  • 10
6

In Web.Config Make sure connection string doesn't have double slash server=(local)\\SQLEXPRESS
I removed the extra slash and it worked, when I had the same issue. server=(local)\SQLEXPRESS

Note: You do need the double slash in your .cs files if you define your connection string as a string or you may get "Unrecognized escape sequence."

Alex Wachira
  • 1,225
  • 16
  • 19
4

I've had this problems,and in my case is was becouse there were "connection string contain a double-slash between the server name and the database instance name".

Avinash
  • 49
  • 1
2

you need to modify your connection string according to your new server

Muhammad Akhtar
  • 51,913
  • 37
  • 138
  • 191
  • 1
    Sounds like you are using SQL membership provider for ASP.NET, and maybe you use SQLExpress, which is usually installed and accessed locally. You need to update the connection string when you copy your site anywhere else to make sure ASP.NET can find the correct SQL Server database instance. – Lex Li Dec 02 '09 at 06:57
1

You're getting an error when you try to open a connection to the database. Do you specify credentials in your connection string? If not, the identity of your app pool is probably different between the 2 servers.

David
  • 34,223
  • 3
  • 62
  • 80
0

I've had this problem, and in my case it was because there were multiple SQL Server instances installed on the same machine and they were all configured to use the same port.

Wes
  • 1,059
  • 13
  • 18