Hacktoberfest 2026: as issues que os mantenedores marcaram para outubro, abertas e boas para iniciantes. Ver issues do Hacktoberfest

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

Aberta
#110 1 comentário 0 reações 0 responsáveis Ver no GitHub

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
4/5
Tempo estimado
3-5 dias
Facilidade para iniciantes
25/100
Tipo de issue
Bug
Clareza
Precisa de esclarecimento
Status de atividade
Estagnada
Stack de tecnologia
csharp, sql
Domínio
databases, testing-qa

Direção de pesquisa

Comece reproduzindo o teste com falha relacionado a SqlAgentService.ExecuteJob e inspecione o app.config e as referências de pacotes do projeto de testes separado em .NET 4.8. Compare as versões de Microsoft.Identity.Client resolvidas pelo projeto de testes e por Microsoft.SqlServer.SqlManagementObjects e, em seguida, verifique se o teste não gera mais o erro de carregamento do assembly.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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?
Linguagem predominante
C#
Estrelas
143
Forks
28
Métricas de merge de PRs
Nenhum PR com merge em 30d

Guia de contribuição

Nenhum guia de contribuição indexado para este repositório

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de microsoft/sqlmanagementobjects

Todas as issues de microsoft/sqlmanagementobjects

Issues semelhantes

Mais issues de C#

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.