microsoft / microsoft/sqlmanagementobjects
Could not load file or assembly Microsoft.Identity.Client, Version=4.22.0.0
Chưa có ai nhận issue này.
- Ngôn ngữ chính
- C#
- Star
- 143
- Fork
- 28
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Mô tả
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?
Hướng dẫn đóng góp
Chưa lập chỉ mục được hướng dẫn đóng góp cho kho mã nguồn này
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Hướng nghiên cứu
Bắt đầu bằng cách tái hiện bài kiểm thử bị lỗi liên quan đến SqlAgentService.ExecuteJob và kiểm tra app.config cùng các tham chiếu gói của dự án kiểm thử .NET 4.8 riêng biệt. So sánh các phiên bản Microsoft.Identity.Client được dự án kiểm thử và Microsoft.SqlServer.SqlManagementObjects phân giải, sau đó xác minh rằng bài kiểm thử không còn phát sinh lỗi tải assembly.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Đánh giá
- Công nghệ
- csharp, sql
- Lĩnh vực
- databases, testing-qa
- Loại issue
- Lỗi
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức độ hoạt động
- Đình trệ
- Độ rõ ràng
- Cần làm rõ
- Mức phù hợp với người mới
- 25/100