microsoft / microsoft/sqlmanagementobjects

Could not load file or assembly Microsoft.Identity.Client, Version=4.22.0.0

Aperta
#110 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Lingua principale
C#
Stelle
143
Fork
28
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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:

  1. The application itself is working fine (the main project), this error is only happening in my unit test project
  2. 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?

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia riproducendo il test non riuscito relativo a SqlAgentService.ExecuteJob e analizza app.config e i riferimenti ai pacchetti del progetto di test .NET 4.8 separato. Confronta le versioni di Microsoft.Identity.Client risolte dal progetto di test e da Microsoft.SqlServer.SqlManagementObjects, quindi verifica che il test non generi più l'errore di caricamento dell'assembly.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp, sql
Ambito
databases, testing-qa
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Ferma
Chiarezza
Da chiarire
Idoneità per principianti
25/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.