microsoft / microsoft/sqlmanagementobjects
Could not load file or assembly Microsoft.Identity.Client, Version=4.22.0.0
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- C#
- Estrellas
- 143
- Forks
- 28
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Descripción
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?
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Comienza reproduciendo la prueba que falla alrededor de SqlAgentService.ExecuteJob e inspecciona el app.config y las referencias de paquetes del proyecto de pruebas independiente de .NET 4.8. Compara las versiones de Microsoft.Identity.Client resueltas por el proyecto de pruebas y por Microsoft.SqlServer.SqlManagementObjects y, a continuación, verifica que la prueba ya no genere el error de carga del ensamblado.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- csharp, sql
- Área
- databases, testing-qa
- Tipo de issue
- Error
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Estado de actividad
- Estancado
- Claridad
- Necesita aclaración
- Aptitud para principiantes
- 25/100