2009-12-02 81 views
9

我有一個在我的系統中完美工作的web應用程序。但是,當我將它複製到另一個系統時,我無法登錄到應用程序。有一個錯誤:asp.net中的實例失敗

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 

什麼可能是這種錯誤的原因?我怎麼能解決這個問題?

回答

0

當您嘗試打開到數據庫的連接時出現錯誤。你是否在連接字符串中指定了憑據?否則,您的應用程序池的身份在兩臺服務器之間可能不同。

2

您需要修改連接字符串根據您的新服務器

+1

聽起來就像您正在使用ASP.NET的SQL成員資格提供程序,也許您使用通常在本地安裝和訪問的SQLExpress。當您在其他任何位置複製站點時,您需要更新連接字符串以確保ASP.NET能夠找到正確的SQL Server數據庫實例。 – 2009-12-02 06:57:59

39

請問您的連接字符串包含服務器名稱和數據庫實例名之間的雙斜線?

例如。本地主機\\ SQLEXPRESS

它應該是:本地主機\ SQLEXPRESS

參見:

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

+0

謝謝,今天有這個問題。 – 2010-09-11 00:24:06

+0

我有一個稍微不同的問題:在我的情況下,反斜槓是在servername的末尾:'Server =。\ SQLEXPRESS \; Database = ...'。我將其更正爲:'Server =。\ SQLEXPRESS; Database = ...'! – 2013-10-15 21:49:29

0

我有這個問題,在我的情況,這是因爲有多個SQL Server實例安裝在同一臺計算機上,並且它們都配置爲使用相同的端口。

3

我有這個問題,在我的情況是因爲有「連接字符串包含服務器名稱和數據庫實例名稱之間的雙斜槓」。

2

Web.Config中 確保連接字符串沒有雙斜槓server=(local)\\SQLEXPRESS
我刪除了額外的斜線和它的工作,當我有同樣的問題。 server=(local)\SQLEXPRESS

注:「無法識別的轉義序列」你確實需要雙斜槓在您的.cs文件,如果你定義自己的連接字符串作爲string或者你可能會得到