2009-12-02 2 views
9

J'ai une application Web qui fonctionne parfaitement dans mon système. Cependant, lorsque je l'ai copié sur un autre système, je n'ai pas pu me connecter à l'application. Il y a une erreur:Échec d'instance dans 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 

Quelle pourrait être la raison d'une telle erreur? Comment pourrais-je résoudre ceci?

Répondre

0

Vous obtenez une erreur lorsque vous essayez d'ouvrir une connexion à la base de données. Est-ce que vous spécifiez les informations d'identification dans votre chaîne de connexion? Sinon, l'identité de votre pool d'applications est probablement différente entre les deux serveurs.

2

vous devez modifier la chaîne de connexion en fonction de votre nouveau serveur

+1

Il semble que vous utilisiez le fournisseur d'appartenances SQL pour ASP.NET et que vous utilisiez SQLExpress, qui est généralement installé et accédé localement. Vous devez mettre à jour la chaîne de connexion lorsque vous copiez votre site n'importe où ailleurs pour vous assurer qu'ASP.NET peut trouver l'instance de base de données SQL Server correcte. –

39

Votre chaîne de connexion contient une double barre oblique entre le nom du serveur et le nom d'instance de base de données?

par ex. localhost \\ SQLEXPRESS

Il devrait être: localhost \ SQLEXPRESS

Voir:

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

+0

Merci, avait exactement ce problème aujourd'hui. –

+0

J'ai eu un problème légèrement différent: dans mon cas, le backslash était à la fin du nom de serveur: 'Server =. \ SQLEXPRESS \; Database = ...'. Je l'ai corrigé à: 'Server =. \ SQLEXPRESS; Database = ...'! –

0

J'ai eu ce problème, et dans mon cas, il était parce qu'il y avait plusieurs instances SQL Server installés sur la même machine et ils ont tous été configurés pour utiliser le même port.

3

J'ai eu ce problème, et dans mon cas, c'était parce qu'il y avait "une chaîne de connexion contenant une double barre oblique entre le nom du serveur et le nom de l'instance de base de données".

2

Dans Web.Config Faire chaîne de connexion que ne pas double barre oblique server=(local)\\SQLEXPRESS
j'ai enlevé la barre oblique supplémentaire et cela a fonctionné, quand j'eu le même problème. server=(local)\SQLEXPRESS

Note: Vous avez besoin de la double barre oblique dans vos fichiers .cs si vous définissez votre chaîne de connexion en tant que string ou vous pouvez obtenir « séquence d'échappement non reconnue. »

Questions connexes