Bonjour,
Je travaille sur un projet .NET 4.7.2 MVC, avec une base de données local SQL Server.
Du jour au lendemain, j'obtiens des erreurs d'accès à ma base locale, et j'ai passé des heures à essayer de corriger cela en vain.

J'ai une connexion string tout à fait standard dans mon web.config :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
<add name="maConnexion" providerName="System.Data.SqlClient" connectionString="Server=SRVDEV0\SQL2019; Database=ma_base; Integrated Security=true;" />
J'arrive à ouvrir ma base, et à l'interroger avec SQL Server Management Studio 2018.

Voici l'erreur que j'obtiens dans l'Event Viewer :

Event code: 3005
Event message: Une exception non gérée s'est produite.
Event time: 07/04/2021 11:24:37
Event time (UTC): 07/04/2021 09:24:37
Event ID: 80239a6e44574826a897a16079f8aa5a
Event sequence: 2
Event occurrence: 1
Event detail code: 0

Application information:
Application domain: /LM/W3SVC/11/ROOT-19-132622610500288104
Trust level: Full
Application Virtual Path: /
Application Path: C:\Sources\pndv.website.new2\kooboo\Kooboo.CMS.Web\
Machine name: WKS-NICE-141

Process information:
Process ID: 18844
Process name: w3wp.exe
Account name: PCLE\moi

Exception information:
Exception type: HttpException
Exception message: Une erreur liée au réseau ou spécifique à l'instance s'est produite lors de l'établissement d'une connexion à SQL Server. Le serveur est introuvable ou n'est pas accessible. Vérifiez que le nom de l'instance est correct et que SQL Server est configuré pour autoriser les connexions distantes. (provider: SQL Network Interfaces, error: 26 - Erreur lors de la localisation du serveur/de l'instance spécifiés)
à System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app)
à System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers)
à System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context)
à System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context)
à System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)

Une erreur liée au réseau ou spécifique à l'instance s'est produite lors de l'établissement d'une connexion à SQL Server. Le serveur est introuvable ou n'est pas accessible. Vérifiez que le nom de l'instance est correct et que SQL Server est configuré pour autoriser les connexions distantes. (provider: SQL Network Interfaces, error: 26 - Erreur lors de la localisation du serveur/de l'instance spécifiés)
à System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
à System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
à System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(DbConnectionPool pool, DbConnection owningObject, DbConnectionOptions options, DbConnectionPoolKey poolKey, DbConnectionOptions userOptions)
à System.Data.ProviderBase.DbConnectionPool.CreateObject(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
à System.Data.ProviderBase.DbConnectionPool.UserCreateRequest(DbConnection owningObject, DbConnectionOptions userOptions, DbConnectionInternal oldConnection)
à System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)
à System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
à System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
à System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
à System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
à System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
à System.Data.SqlClient.SqlConnection.Open()
à Kooboo.CMS.Content.Persistence.SqlServer.SQLServerHelper.TestConnection(String connectionString) dans C:\Sources\pndv.website.new2\kooboo\Kooboo.CMS.Content.Persistence.SqlServer\SQLServerHelper.cs:ligne 28
à Kooboo.CMS.Content.Persistence.SqlServer.RepositoryProvider.TestDbConnection() dans C:\Sources\pndv.website.new2\kooboo\Kooboo.CMS.Content.Persistence.SqlServer\RepositoryProvider.cs:ligne 55
à Kooboo.CMS.Content.Persistence.Caching.RepositoryProvider.TestDbConnection() dans C:\Sources\pndv.website.new2\kooboo\Kooboo.CMS.Content\Persistence\Caching\RepositoryProvider.cs:ligne 152
à Kooboo.CMS.Web.KoobooCMSHttpApplicationEvents.Application_Start(Object sender, EventArgs e) dans C:\Sources\pndv.website.new2\kooboo\Kooboo.CMS.Web\KoobooCMSHttpApplicationEvents.cs:ligne 144
à Kooboo.CMS.Common.HttpApplicationHooker.<>c__DisplayClass2_0.<Application_Start>b__0(IHttpApplicationEvents events) dans C:\Sources\pndv.website.new2\kooboo\Kooboo.CMS.Common\HttpApplicationHooker.cs:ligne 45
à Kooboo.CMS.Common.HttpApplicationHooker.RunEvents(Action`1 action) dans C:\Sources\pndv.website.new2\kooboo\Kooboo.CMS.Common\HttpApplicationHooker.cs:ligne 24
à Kooboo.CMS.Common.HttpApplicationHooker.Application_Start(Object sender, EventArgs e) dans C:\Sources\pndv.website.new2\kooboo\Kooboo.CMS.Common\HttpApplicationHooker.cs:ligne 43
à Kooboo.CMS.Web.MvcApplication.Application_Start(Object sender, EventArgs e) dans C:\Sources\pndv.website.new2\kooboo\Kooboo.CMS.Web\Global.asax.cs:ligne 43



Request information:
Request URL: http://local.congres-pneumologie.key...tes/home/index
Request path: /Sites/home/index
User host address: 127.0.0.1
User:
Is authenticated: False
Authentication Type:
Thread account name: PCLE\moi

Thread information:
Thread ID: 209
Thread account name: PCLE\moi
Is impersonating: False
Stack trace: à System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app)
à System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers)
à System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context)
à System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context)
à System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)


Custom event details:
Voici le code de connextion à la bd :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
        public static bool TestConnection(string connectionString)
        {
            using (var conn = new SqlConnection(connectionString))
            {
                conn.Open();
                return conn.State == ConnectionState.Open;
            }
        }
Ce code plante avec l'erreur suivante :
System.Data.SqlClient.SqlException: 'Une erreur liée au réseau ou spécifique à l'instance s'est produite lors de l'établissement d'une connexion à SQL Server. Le serveur est introuvable ou n'est pas accessible. Vérifiez que le nom de l'instance est correct et que SQL Server est configuré pour autoriser les connexions distantes. (provider: SQL Network Interfaces, error: 26 - Erreur lors de la localisation du serveur/de l'instance spécifiés)'

This exception was originally thrown at this call stack:
System.Data.SqlClient.SqlInternalConnection.OnError(System.Data.SqlClient.SqlException, bool, System.Action<System.Action>)
ou
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
This exception was originally thrown at this call stack:
    System.Data.SqlClient.SqlInternalConnection.OnError(System.Data.SqlClient.SqlException, bool, System.Action<System.Action>)
    System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(System.Data.SqlClient.TdsParserStateObject, bool, bool)
    System.Data.SqlClient.TdsParser.Connect(System.Data.SqlClient.ServerInfo, System.Data.SqlClient.SqlInternalConnectionTds, bool, long, bool, bool, bool, bool, bool, System.Data.SqlClient.SqlAuthenticationMethod, bool, System.Data.SqlClient.SqlAuthenticationProviderManager)
    System.Data.SqlClient.SqlInternalConnectionTds.AttemptOneLogin(System.Data.SqlClient.ServerInfo, string, System.Security.SecureString, bool, System.Data.ProviderBase.TimeoutTimer, bool, bool, bool)
    System.Data.SqlClient.SqlInternalConnectionTds.LoginNoFailover(System.Data.SqlClient.ServerInfo, string, System.Security.SecureString, bool, System.Data.SqlClient.SqlConnectionString, System.Data.SqlClient.SqlCredential, System.Data.ProviderBase.TimeoutTimer)
ou
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
This exception was originally thrown at this call stack:
    System.Data.SqlClient.SqlInternalConnectionTds.SqlInternalConnectionTds(System.Data.ProviderBase.DbConnectionPoolIdentity, System.Data.SqlClient.SqlConnectionString, System.Data.SqlClient.SqlCredential, object, string, System.Security.SecureString, bool, System.Data.SqlClient.SqlConnectionString, System.Data.SqlClient.SessionData, System.Data.ProviderBase.DbConnectionPool, string, bool, System.Data.SqlClient.SqlAuthenticationProviderManager)
    System.Data.SqlClient.SqlConnectionFactory.CreateConnection(System.Data.Common.DbConnectionOptions, System.Data.Common.DbConnectionPoolKey, object, System.Data.ProviderBase.DbConnectionPool, System.Data.Common.DbConnection, System.Data.Common.DbConnectionOptions)
    System.Data.ProviderBase.DbConnectionFactory.CreatePooledConnection(System.Data.ProviderBase.DbConnectionPool, System.Data.Common.DbConnection, System.Data.Common.DbConnectionOptions, System.Data.Common.DbConnectionPoolKey, System.Data.Common.DbConnectionOptions)
    System.Data.ProviderBase.DbConnectionPool.CreateObject(System.Data.Common.DbConnection, System.Data.Common.DbConnectionOptions, System.Data.ProviderBase.DbConnectionInternal)

Tout ceci semble montrer une erreur de communication entre VS et SQL Server, mais je ne comprends pas où...
Pourriez-vous me débloquer svp ?
Merci