microsoft / microsoft/sqlmanagementobjects

NullReferenceException with Microsoft.Data.SqlClient 5.2.0 and with event handler for Backup.PercentComplete

Đang mở
#162 2 bình luận 0 reaction 0 người được giao Xem trên GitHub

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ả

In our app we reference both NuGet-Packages Microsoft.SqlServer.SqlManagementObjects and Microsoft.Data.SqlClient.
We use SMO for many DB-related tasks, incl. Backup of the app databases.
We refresh the NuGet references regularly, actually we use Microsoft.SqlServer.SqlManagementObjects 171.30.0 and Microsoft.Data.SqlClient 5.1.5.
Everything worked fine until we updated Microsoft.Data.SqlClient to the actual version 5.2.0. Now our backup code throws NullReferenceException. As a workaround we switched back to Microsoft.Data.SqlClient 5.1.5.
We were able to reproduce the issue with the sample from https://learn.microsoft.com/en-us/sql/relational-databases/server-management-objects-smo/tasks/backing-up-and-restoring-databases-and-transaction-logs?view=sql-server-ver16#backing-up-databases-and-transaction-logs-in-visual-c
The only difference is the added event handler for Backup.PercentComplete. With it, the sample throws NullReferenceException when calling Backup.SqlBackup() and using SqlClient 5.2.0. The same code works fine with SqlClient 5.1.5 or earlier.

The sample is attached to the issue.
MS_SMO_BackupBug.zip

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu với tệp đính kèm MS_SMO_BackupBug.zip và SMO backup sample được liên kết, tập trung vào handler Backup.PercentComplete và lệnh gọi Backup.SqlBackup(). So sánh hành vi với Microsoft.Data.SqlClient 5.1.5 và 5.2.0, sau đó xác minh rằng sample hoàn tất mà không xảy ra NullReferenceException trên 5.2.0 trong khi handler vẫn được bật.

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
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
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.