microsoft / microsoft/sqlmanagementobjects

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

オープン
#110 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
C#
スター
143
フォーク
28
PR マージ指標
30日以内にマージされた PR はありません

説明

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?

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、SqlAgentService.ExecuteJob に関する失敗しているテストを再現し、別の .NET 4.8 テストプロジェクトの app.config とパッケージ参照を調べます。テストプロジェクトと Microsoft.SqlServer.SqlManagementObjects によって解決される Microsoft.Identity.Client のバージョンを比較し、その後、テストでアセンブリ読み込みエラーが発生しなくなったことを確認します。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
csharp, sql
領域
databases, testing-qa
issue の種類
バグ
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
25/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。