本文介绍了asp.net中的实例失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在我的系统中正常工作的Web应用程序。但是,当我将其复制到另一个系统时,我无法登录到应用程序。在/'应用程序中出现错误:

 服务器错误。 
---------------------------------------------- ----------------------------------

实例失败。
说明:在执行当前Web请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误的更多信息及其在代码中的起始位置。

异常详细信息:System.InvalidOperationException:实例失败。

源错误:

在执行当前Web请求期间生成了未处理的异常。有关异常的来源和位置的信息可以使用下面的异常堆栈跟踪来识别。

堆栈跟踪:


[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选项)+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.DbConnectio nClosed.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&状态,字符串&密码,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




-------------------- -------------------------------------------------- ----------
版本信息:Microsoft .NET Framework版本:2.0.50727.3053; ASP.NET版本:2.0.50727.3053

可能是这样的错误的原因?如何解决这个问题?

解决方案

您的连接字符串是否包含服务器名称和数据库实例名称之间的双斜杠?



例如。 localhost \\\SQLEXPRESS



应该是:localhost\SQLEXPRESS



请参阅:




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?

解决方案

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

这篇关于asp.net中的实例失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 01:54