microsoft / microsoft/sqlmanagementobjects
Could not load file or assembly Microsoft.Identity.Client, Version=4.22.0.0
Personne n'a encore pris cette issue.
- Langage dominant
- C#
- Étoiles
- 143
- Forks
- 28
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
I have a .NET 4.8 framework Windows application that is using Microsoft.SqlServer.SqlManagementObjects (v161.47027.0) in its own class. I am unit testing that class in a separate .NET 4.8 library test project.
However when I run a test like so:
[Test]
public void SqlAgentJobDoesntExist_ThrowsException()
{
var connection = new SqlConnectionStringBuilder(ConnectionString); //ConnectionString coming from app.config in the test project
var sqlAgent = new SqlAgentService(connection);
Assert.Throws<NullReferenceException>(() => { var result = sqlAgent.ExecuteJob("NotFound"); });
}
It is throwing an error around this bit of code in my service class:
public CompletionResult ExecuteJob(string jobName)
{
try
{
var connection = new ServerConnection(_connectionBuilder.DataSource, _connectionBuilder.UserID, _connectionBuilder.Password);
var server = new Server(connection);
var job = server.JobServer.Jobs[jobName]; //<-- throwing error here
...
Error:
Microsoft.SqlServer.Management.Common.ConnectionFailureException : Failed to connect to server XXXXXXXXXXX.
----> System.TypeInitializationException : The type initializer for 'Microsoft.Data.SqlClient.SqlAuthenticationProviderManager' threw an exception.
----> System.IO.FileLoadException : Could not load file or assembly 'Microsoft.Identity.Client, Version=4.22.0.0, Culture=neutral, PublicKeyToken=0a613f4dd989e8ae' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Two reasons this is odd:
- The application itself is working fine (the main project), this error is only happening in my unit test project
- It's odd because SMO already installs Microsoft.Identity.Client as a dependency when adding as a NuGet package. Why is it asking for this older 4.22 version?
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Piste de recherche
Commencez par reproduire le test en échec autour de SqlAgentService.ExecuteJob et examinez le fichier app.config ainsi que les références de packages du projet de test .NET 4.8 distinct. Comparez les versions de Microsoft.Identity.Client résolues par le projet de test et par Microsoft.SqlServer.SqlManagementObjects, puis vérifiez que le test ne déclenche plus l’erreur de chargement d’assembly.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Évaluation
- Stack technique
- csharp, sql
- Domaine
- databases, testing-qa
- Type d'issue
- Bug
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Activité
- À l'abandon
- Clarté
- À clarifier
- Accessibilité débutants
- 25/100